SaveToDB Problem

Results 1 to 13 of 13
  1. #1
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    SaveToDB Problem

    I once again have another problem with the SaveToDB, I'd be really appreciated if you guys could help me once again! (:

    PHP Code:
    Error saving IGN Level1 Job1000
    com
    .mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExceptionYou have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 5' at line 1
        at sun
    .reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
        
    at com.mysql.jdbc.Util.getInstance(Util.java:384)
        
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
        
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562)
        
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494)
        
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960)
        
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114)
        
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2696)
        
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2105)
        
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2398)
        
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2316)
        
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2301)
        
    at client.MapleCharacter.saveToDB(MapleCharacter.java:3891)
        
    at client.MapleClient.disconnect(MapleClient.java:673)
        
    at net.MapleServerHandler.sessionClosed(MapleServerHandler.java:105)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionClosed(DefaultIoFilterChain.java:642)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:382)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:47)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:750)
        
    at org.apache.mina.filter.codec.ProtocolCodecFilter.sessionClosed(ProtocolCodecFilter.java:369)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:382)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:47)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:750)
        
    at org.apache.mina.core.filterchain.IoFilterAdapter.sessionClosed(IoFilterAdapter.java:88)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:382)
        
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionClosed(DefaultIoFilterChain.java:375)
        
    at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionDestroyed(IoServiceListenerSupport.java:244)
        
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.removeNow(AbstractPollingIoProcessor.java:600)
        
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.removeSessions(AbstractPollingIoProcessor.java:560)
        
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$800(AbstractPollingIoProcessor.java:67)
        
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1132)
        
    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
        
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        
    at java.lang.Thread.run(Thread.java:744)

    --------------------------------- 


  2. #2
    Member s4nta is offline
    MemberRank
    Sep 2013 Join Date
    82Posts

    Re: SaveToDB Problem

    have you tried checking your sql syntax because that's what the console is telling you to do

  3. #3
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: SaveToDB Problem

    Quote Originally Posted by s4nta View Post
    have you tried checking your sql syntax because that's what the console is telling you to do
    What do i check?

  4. #4
    desk.getCoffee().drink(); AngelSpirit is offline
    MemberRank
    Jul 2010 Join Date
    CanadaLocation
    318Posts

    Re: SaveToDB Problem

    You have exactly the same problem as last time...
    Code:
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 5' at line 1
    Code:
        at client.MapleCharacter.saveToDB(MapleCharacter.java:3891)

  5. #5
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: SaveToDB Problem

    Quote Originally Posted by AngelSpirit View Post
    You have exactly the same problem as last time...
    Code:
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 5' at line 1
    Code:
        at client.MapleCharacter.saveToDB(MapleCharacter.java:3891)
    But this time it's
    PHP Code:
    WHERE id 5' at line 1 
    :/

  6. #6
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: SaveToDB Problem

    Still looking for a fix

  7. #7
    I'm overrated. Fraysa is offline
    MemberRank
    Apr 2008 Join Date
    4,891Posts

    Re: SaveToDB Problem

    Post the query you're trying to execute, what, are we supposed to guess it? A little more serious please.

  8. #8
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: SaveToDB Problem

    Quote Originally Posted by Fraysa View Post
    Post the query you're trying to execute, what, are we supposed to guess it? A little more serious please.
    There is no query that I'm trying to execute...lol. I'll post my maple character if that helps?

  9. #9
    Member Drum is offline
    MemberRank
    Jul 2013 Join Date
    80Posts

    Re: SaveToDB Problem

    I don't think anyone can be bothered helping you haha, you're not even trying. You have already been helped, we're not here to do it all for you. Maybe not exactly, but you have the same problem as in your last thread.

    Have a look online at what the syntax for a SQL query with a WHERE clause should be.

  10. #10
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: SaveToDB Problem

    Quote Originally Posted by Drum View Post
    I don't think anyone can be bothered helping you haha, you're not even trying. You have already been helped, we're not here to do it all for you. Maybe not exactly, but you have the same problem as in your last thread.

    Have a look online at what the syntax for a SQL query with a WHERE clause should be.
    I've been helped, but the error continues. I'm sorry I can't be as smart as you, but I'm trying to know how to fix this so if the problem happens again. I would know where to go to fix the problem. Also, this isn't the same problem as my last thread whereas this one is 'WHERE id = 5' not 'WHERE id = 1'. I'm not here to be flamed, I'm here to get help. So don't take this in any offence, but if you're not here to help, the door is to there. Thanks. (:

    I've also looked online, but no results.

  11. #11
    desk.getCoffee().drink(); AngelSpirit is offline
    MemberRank
    Jul 2010 Join Date
    CanadaLocation
    318Posts

    Re: SaveToDB Problem


    Just....just post the MapleCharacter class so we can end this.

  12. #12
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: SaveToDB Problem

    Quote Originally Posted by AngelSpirit View Post

    Just....just post the MapleCharacter class so we can end this.
    Thank you (:

    Spoiler:
    PHP Code:
    /*  
     This file is part of the OdinMS Maple Story Server 
     Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
     Matthias Butz <matze@odinms.de> 
     Jan Christian Meyer <vimes@odinms.de> 

     This program is free software: you can redistribute it and/or modify 
     it under the terms of the GNU Affero General Public License as 
     published by the Free Software Foundation version 3 as published by 
     the Free Software Foundation. You may not use, modify or distribute 
     this program unader any cother version of the GNU Affero General Public 
     License. 

     This program is distributed in the hope that it will be useful, 
     but WITHOUT ANY WARRANTY; without even the implied warranty of 
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     GNU Affero General Public License for more details. 

     You should have received a copy of the GNU Affero General Public License 
     along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     */ 
    package client; 

    import java.awt.Point; 
    import java.io.IOException; 
    import java.lang.ref.WeakReference; 
    import java.net.InetAddress; 
    import java.security.InvalidParameterException; 
    import java.sql.Connection; 
    import java.sql.Date; 
    import java.sql.PreparedStatement; 
    import java.sql.ResultSet; 
    import java.sql.SQLException; 
    import java.sql.Statement; 
    import java.sql.Timestamp; 
    import java.text.DecimalFormat; 
    import java.text.NumberFormat; 
    import java.util.ArrayList; 
    import java.util.Arrays; 
    import java.util.Calendar; 
    import java.util.Collection; 
    import java.util.Collections; 
    import java.util.EnumMap; 
    import java.util.Iterator; 
    import java.util.LinkedHashMap; 
    import java.util.LinkedHashSet; 
    import java.util.LinkedList; 
    import java.util.List; 
    import java.util.Map; 
    import java.util.Map.Entry; 
    import java.util.Set; 
    import java.util.concurrent.ScheduledFuture; 
    import java.util.concurrent.atomic.AtomicInteger; 
    import java.util.regex.Pattern; 

    import net.server.PlayerBuffValueHolder; 
    import net.server.PlayerCoolDownValueHolder; 
    import net.server.PlayerDiseaseValueHolder; 
    import net.server.Server; 
    import net.server.channel.Channel; 
    import net.server.guild.MapleGuild; 
    import net.server.guild.MapleGuildCharacter; 
    import net.server.world.MapleMessenger; 
    import net.server.world.MapleMessengerCharacter; 
    import net.server.world.MapleParty; 
    import net.server.world.MaplePartyCharacter; 
    import net.server.world.PartyOperation; 
    import net.server.world.World; 
    import scripting.event.EventInstanceManager; 
    import server.CashShop; 
    import server.MapleInventoryManipulator; 
    import server.MapleItemInformationProvider; 
    import server.MaplePlayerShop; 
    import server.MaplePortal; 
    import server.MapleShop; 
    import server.MapleStatEffect; 
    import server.MapleStorage; 
    import server.MapleTrade; 
    import server.TimerManager; 
    import server.events.MapleEvents; 
    import server.events.RescueGaga; 
    import server.events.gm.MapleFitness; 
    import server.events.gm.MapleOla; 
    import server.life.MapleLifeFactory; 
    import server.life.MapleMonster; 
    import server.life.MobSkill; 
    import server.maps.AbstractAnimatedMapleMapObject; 
    import server.maps.FieldLimit; 
    import server.maps.HiredMerchant; 
    import server.maps.MapleDoor; 
    import server.maps.MapleMap; 
    import server.maps.MapleMapEffect; 
    import server.maps.MapleMapFactory; 
    import server.maps.MapleMapObject; 
    import server.maps.MapleMapObjectType; 
    import server.maps.MapleSummon; 
    import server.maps.PlayerNPCs; 
    import server.maps.SavedLocation; 
    import server.maps.SavedLocationType; 
    import server.minigames.AbstractMinigame; 
    import server.minigames.IMinigame; 
    import server.partyquest.MonsterCarnival; 
    import server.partyquest.MonsterCarnivalParty; 
    import server.partyquest.PartyQuest; 
    import server.quest.MapleQuest; 
    import server.quest.custom.CustomQuest; 
    import server.quest.custom.CustomQuestProvider; 
    import tools.DatabaseConnection; 
    import tools.FilePrinter; 
    import tools.MaplePacketCreator; 
    import tools.Pair; 
    import tools.Randomizer; 
    import client.autoban.AutobanManager; 
    import client.inventory.Equip; 
    import client.inventory.Item; 
    import client.inventory.ItemFactory; 
    import client.inventory.MapleInventory; 
    import client.inventory.MapleInventoryType; 
    import client.inventory.MaplePet; 
    import client.inventory.MapleWeaponType; 
    import client.inventory.ModifyInventory; 
    import client.occupations.OccupationEntry; 
    import client.occupations.OccupationFactory; 
    import client.occupations.OccupationInfo; 
    import client.occupations.powers.OccupationPower; 
    import constants.ExpTable; 
    import constants.ItemConstants; 
    import constants.ServerConstants; 
    import constants.skills.Bishop; 
    import constants.skills.BlazeWizard; 
    import constants.skills.Corsair; 
    import constants.skills.Crusader; 
    import constants.skills.DarkKnight; 
    import constants.skills.DawnWarrior; 
    import constants.skills.FPArchMage; 
    import constants.skills.GM; 
    import constants.skills.Hermit; 
    import constants.skills.ILArchMage; 
    import constants.skills.Magician; 
    import constants.skills.Marauder; 
    import constants.skills.Priest; 
    import constants.skills.Ranger; 
    import constants.skills.Sniper; 
    import constants.skills.Spearman; 
    import constants.skills.SuperGM; 
    import constants.skills.Swordsman; 
    import constants.skills.ThunderBreaker; 

    public class MapleCharacter extends AbstractAnimatedMapleMapObject { 

        private static final String LEVEL_200 = "[Congrats] %s has reached Level 200! Congratulate %s on such an amazing achievement!"; 
        private static final int[] DEFAULT_KEY = { 18, 65, 2, 23, 3, 4, 5, 6, 16, 17, 19, 25, 26, 27, 31, 34, 35, 37, 38, 
            40, 43, 44, 45, 46, 50, 56, 59, 60, 61, 62, 63, 64, 57, 48, 29, 7, 24, 33, 41, 39 }; 
        private static final int[] DEFAULT_TYPE = { 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 
            4, 5, 6, 6, 6, 6, 6, 6, 5, 4, 5, 4, 4, 4, 4, 4 }; 
        private static final int[] DEFAULT_ACTION = { 0, 106, 10, 1, 12, 13, 18, 24, 8, 5, 4, 19, 14, 15, 2, 17, 11, 3, 20, 
            16, 9, 50, 51, 6, 7, 53, 100, 101, 102, 103, 104, 105, 54, 22, 52, 21, 25, 26, 23, 27 }; 
        private int world; 
        private int accountid, id; 
        private int rank, rankMove, jobRank, jobRankMove; 
        private int level, str, dex, luk, int_, hp, maxhp, mp, maxmp; 
        private int hpMpApUsed; 
        private int hair; 
        private int face; 
        private int remainingAp, remainingSp; 
        private int fame; 
        private int initialSpawnPoint; 
        private int mapid; 
        private int gender; 
        private int currentPage, currentType = 0, currentTab = 1; 
        private int chair; 
        private int itemEffect; 
        private int guildid, guildrank, allianceRank; 
        private int messengerposition = 4; 
        private int slots = 0; 
        private int energybar; 
        private int gmLevel; 
        private int ci = 0; 
        private MapleFamily family; 
        private int familyId; 
        private int bookCover; 
        private int markedMonster = 0; 
        private int battleshipHp = 0; 
        private int mesosTraded = 0; 
        private int possibleReports = 10; 
        private int dojoPoints, vanquisherStage, dojoStage, dojoEnergy, vanquisherKills; 
        private int warpToId; 
        private int expRate = 1, mesoRate = 1, dropRate = 1; 
        private int omokwins, omokties, omoklosses, matchcardwins, matchcardties, matchcardlosses; 
        private int married; 
        private long dojoFinish, lastfametime, lastUsedCashItem, lastHealed; 
        private transient int localmaxhp, localmaxmp, localstr, localdex, localluk, localint_, magic, watk; 
        private boolean hidden, canDoor = true, Berserk, hasMerchant; 
        private int linkedLevel = 0; 
        private String linkedName = null; 
        private boolean finishedDojoTutorial, dojoParty; 
        private String name; 
        private String chalktext; 
        private String search = null; 
        private AtomicInteger exp = new AtomicInteger(); 
        private AtomicInteger gachaexp = new AtomicInteger(); 
        private AtomicInteger meso = new AtomicInteger(); 
        private int merchantmeso; 
        private BuddyList buddylist; 
        private EventInstanceManager eventInstance = null; 
        private HiredMerchant hiredMerchant = null; 
        private MapleClient client; 
        private MapleGuildCharacter mgc = null; 
        private MaplePartyCharacter mpc = null; 
        private MapleInventory[] inventory; 
        private MapleJob job = MapleJob.BEGINNER; 
        private MapleMap map, dojoMap;// Make a Dojo pq instance 
        private MapleMessenger messenger = null; 
        private AbstractMinigame miniGame; 
        private MapleMount maplemount; 
        private MapleParty party; 
        private MaplePet[] pets = new MaplePet[3]; 
        private MaplePlayerShop playerShop = null; 
        private MapleShop shop = null; 
        private MapleSkinColor skinColor = MapleSkinColor.NORMAL; 
        private MapleStorage storage = null; 
        private MapleTrade trade = null; 
        private SavedLocation savedLocations[]; 
        private SkillMacro[] skillMacros = new SkillMacro[5]; 
        private List<Integer> lastmonthfameids; 
        private Map<MapleQuest, MapleQuestStatus> quests; 
        private Set<MapleMonster> controlled = new LinkedHashSet<>(); 
        private Map<Integer, String> entered = new LinkedHashMap<>(); 
        private Set<MapleMapObject> visibleMapObjects = new LinkedHashSet<>(); 
        private Map<Skill, SkillEntry> skills = new LinkedHashMap<>(); 
        private EnumMap<MapleBuffStat, MapleBuffStatValueHolder> effects = new EnumMap<>(MapleBuffStat.class); 
        private Map<Integer, MapleKeyBinding> keymap = new LinkedHashMap<>(); 
        private Map<Integer, MapleSummon> summons = new LinkedHashMap<>(); 
        private Map<Integer, MapleCoolDownValueHolder> coolDowns = new LinkedHashMap<>(50); 
        private EnumMap<MapleDisease, DiseaseValueHolder> diseases = new EnumMap<>(MapleDisease.class); 
        private List<MapleDoor> doors = new ArrayList<>(); 
        private ScheduledFuture<?dragonBloodSchedule
        private 
    ScheduledFuture<?> mapTimeLimitTask = null; 
        private ScheduledFuture<?>[] fullnessSchedule = new ScheduledFuture<?>[3]; 
        private ScheduledFuture<?hpDecreaseTask
        private 
    ScheduledFuture<?> beholderHealingSchedule, beholderBuffSchedule, BerserkSchedule; 
        private ScheduledFuture<?expiretask
        private 
    ScheduledFuture<?> recoveryTask; 
        private List<ScheduledFuture<?>> timers = new ArrayList<>(); 
        private 
    NumberFormat nf = new DecimalFormat("#,###,###,###"); 
        private 
    ArrayList<Integerexcluded = new ArrayList<>(); 
        private 
    MonsterBook monsterbook
        private List<
    MapleRingcrushRings = new ArrayList<>(); 
        private List<
    MapleRingfriendshipRings = new ArrayList<>(); 
        private 
    MapleRing marriageRing
        private static 
    String[] ariantroomleader = new String[3]; 
        private static 
    int[] ariantroomslot = new int[3]; 
        private 
    CashShop cashshop
        private 
    long portaldelay 0lastcombo 0
        private 
    short combocounter 0
        private List<
    StringblockedPortals = new ArrayList<>(); 
        private 
    Map<ShortStringarea_info = new LinkedHashMap<>(); 
        private 
    AutobanManager autoban
        private 
    boolean isbanned false
        private 
    ScheduledFuture<?> pendantOfSpirit = null; // 1122017 
        private byte pendantExp = 0, lastmobcount = 0; 
        private int[] trockmaps = new int[5]; 
        private int[] viptrockmaps = new int[10]; 
        private Map<String, MapleEvents> events = new LinkedHashMap<>(); 
        private PartyQuest partyQuest = null; 
        private boolean loggedIn = false; 
        // custom shit begins here 
            private int legend; 
            private int horntail_slyed, pinkbeen_slyed; 
            private int expbonuses; 
        private long[] timestampBuffer = new long[256]; 
        public long jailduration, jailtime; 
        public boolean jailed; 
        public boolean autoreborn; 
        private int reborns, jumppoints, eventpoints; 
        public long tempmutetime, tempmuteduration; 
        public boolean muted, tempmuted, whitechatgm; 
        private Map<CustomQuest, MapleCustomQuestStatus> customQuests; 
        private List<MapleCharacter> trackers = new ArrayList<>(); 
        private MapleCharacter watcher = null; 
        public OccupationEntry occupation; 

        private MapleCharacter() { 
            setStance(0); 
            inventory = new MapleInventory[MapleInventoryType.values().length]; 
            savedLocations = new SavedLocation[SavedLocationType.values().length]; 

            for (MapleInventoryType type : MapleInventoryType.values()) { 
                byte b = 24; 
                if (type == MapleInventoryType.CASH) { 
                    b = 96; 
                } 
                inventory[type.ordinal()] = new MapleInventory(type, (byte) b); 
            } 
            for (int i = 0; i < SavedLocationType.values().length; i++) { 
                savedLocations[i] = null; 
            } 
            quests = new LinkedHashMap<>(); 
            customQuests = new LinkedHashMap<>(); 
            setPosition(new Point(0, 0)); 
        } 

        public static MapleCharacter getDefault(MapleClient c) { 
            MapleCharacter ret = new MapleCharacter(); 
            ret.client = c; 
            ret.gmLevel = c.gmLevel(); 
            ret.hp = 50; 
            ret.maxhp = 50; 
            ret.mp = 5; 
                    ret.expbonuses=0; 
            ret.maxmp = 5; 
            ret.str = 12; 
            ret.dex = 5; 
            ret.int_ = 4; 
            ret.luk = 4; 
            ret.map = null; 
            ret.job = MapleJob.BEGINNER; 
            ret.level = 1; 
            ret.accountid = c.getAccID(); 
            ret.buddylist = new BuddyList(20); 
            ret.maplemount = null; 
                    ret.legend = 0; 
                    ret.pinkbeen_slyed = 0; 
                    ret.horntail_slyed = 0; 
            ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(96); 
            ret.getInventory(MapleInventoryType.USE).setSlotLimit(96); 
            ret.getInventory(MapleInventoryType.SETUP).setSlotLimit(96); 
            ret.getInventory(MapleInventoryType.ETC).setSlotLimit(96); 
            for (int i = 0; i < DEFAULT_KEY.length; i++) { 
                ret.keymap.put(DEFAULT_KEY[i], new MapleKeyBinding(DEFAULT_TYPE[i], DEFAULT_ACTION[i])); 
            } 
            // to fix the map 0 lol 
            for (int i = 0; i < 5; i++) { 
                ret.trockmaps[i] = 999999999; 
            } 
            for (int i = 0; i < 10; i++) { 
                ret.viptrockmaps[i] = 999999999; 
            } 

            if (ret.isGM()) { 
                ret.job = MapleJob.SUPERGM; 
                ret.level = 200; 
                // int[] gmskills = {9001000, 9001001, 9001000, 9101000, 9101001, 9101002, 9101003, 9101004, 9101005, 9101006, 9101007, 9101008}; 
            } 
            return ret; 
        } 

        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(skillIdstartTimelengthtimer)); 
        } 

        public 
    void addCrushRing(MapleRing r) { 
            
    crushRings.add(r); 
        } 

        public 
    MapleRing getRingById(int id) { 
            for (
    MapleRing ring getCrushRings()) { 
                if (
    ring.getRingId() == id) { 
                    return 
    ring
                } 
            } 
            for (
    MapleRing ring getFriendshipRings()) { 
                if (
    ring.getRingId() == id) { 
                    return 
    ring
                } 
            } 
            if (
    getMarriageRing().getRingId() == id) { 
                return 
    getMarriageRing(); 
            } 

            return 
    null
        } 

        public 
    int addDojoPointsByMap() { 
            
    int pts 0
            if (
    dojoPoints 17000) { 
                
    pts + ((getMap().getId() - 1) / 100 100) / 6
                if (!
    dojoParty) { 
                    
    pts++; 
                } 
                
    this.dojoPoints += pts
            } 
            return 
    pts
        } 

        public 
    void addDoor(MapleDoor door) { 
            
    doors.add(door); 
        } 

        public 
    void addExcluded(int x) { 
            
    excluded.add(x); 
        } 

        public 
    void addFame(int famechange) { 
            
    this.fame += famechange
        } 

        public 
    void addFriendshipRing(MapleRing r) { 
            
    friendshipRings.add(r); 
        } 

        public 
    void addHP(int delta) { 
            
    setHp(hp delta); 
            
    updateSingleStat(MapleStat.HPhp); 
        } 

        public 
    void addMesosTraded(int gain) { 
            
    this.mesosTraded += gain
        } 

        public 
    void addMP(int delta) { 
            
    setMp(mp delta); 
            
    updateSingleStat(MapleStat.MPmp); 
        } 

        public 
    void addMPHP(int hpDiffint mpDiff) { 
            
    setHp(hp hpDiff); 
            
    setMp(mp mpDiff); 
            
    updateSingleStat(MapleStat.HPgetHp()); 
            
    updateSingleStat(MapleStat.MPgetMp()); 
        } 

        public 
    void addPet(MaplePet pet) { 
            for (
    int i 03i++) { 
                if (
    pets[i] == null) { 
                    
    pets[i] = pet
                    return; 
                } 
            } 
        } 

        public 
    void addStat(int typeint up) { 
            if (
    type == 1) { 
                
    this.str += up
                
    updateSingleStat(MapleStat.STRstr); 
            } else if (
    type == 2) { 
                
    this.dex += up
                
    updateSingleStat(MapleStat.DEXdex); 
            } else if (
    type == 3) { 
                
    this.int_ += up
                
    updateSingleStat(MapleStat.INTint_); 
            } else if (
    type == 4) { 
                
    this.luk += up
                
    updateSingleStat(MapleStat.LUKluk); 
            } 
        } 

        public 
    int addHP(MapleClient c) { 
            
    MapleCharacter player c.getPlayer(); 
            
    MapleJob jobtype player.getJob(); 
            
    int MaxHP player.getMaxHp(); 
            if (
    player.getHpMpApUsed() > 9999 || MaxHP >= 30000) { 
                return 
    MaxHP
            } 
            if (
    jobtype.isA(MapleJob.BEGINNER)) { 
                
    MaxHP += 8
            } else if (
    jobtype.isA(MapleJob.WARRIOR) || jobtype.isA(MapleJob.DAWNWARRIOR1)) { 
                if (
    player.getSkillLevel(player.isCygnus() ? SkillFactory.getSkill(10000000) : SkillFactory.getSkill(1000001)) > 0) { 
                    
    MaxHP += 20
                } else { 
                    
    MaxHP += 8
                } 
            } else if (
    jobtype.isA(MapleJob.MAGICIAN) || jobtype.isA(MapleJob.BLAZEWIZARD1)) { 
                
    MaxHP += 6
            } else if (
    jobtype.isA(MapleJob.BOWMAN) || jobtype.isA(MapleJob.WINDARCHER1)) { 
                
    MaxHP += 8
            } else if (
    jobtype.isA(MapleJob.THIEF) || jobtype.isA(MapleJob.NIGHTWALKER1)) { 
                
    MaxHP += 8
            } else if (
    jobtype.isA(MapleJob.PIRATE) || jobtype.isA(MapleJob.THUNDERBREAKER1)) { 
                if (
    player.getSkillLevel(player.isCygnus() ? SkillFactory.getSkill(15100000) : SkillFactory.getSkill(5100000)) > 0) { 
                    
    MaxHP += 18
                } else { 
                    
    MaxHP += 8
                } 
            } 
            return 
    MaxHP
        } 

        public 
    int addMP(MapleClient c) { 
            
    MapleCharacter player c.getPlayer(); 
            
    int MaxMP player.getMaxMp(); 
            if (
    player.getHpMpApUsed() > 9999 || player.getMaxMp() >= 30000) { 
                return 
    MaxMP
            } 
            if (
    player.getJob().isA(MapleJob.BEGINNER) || player.getJob().isA(MapleJob.NOBLESSE) || player.getJob().isA(MapleJob.LEGEND)) { 
                
    MaxMP += 6
            } else if (
    player.getJob().isA(MapleJob.WARRIOR) || player.getJob().isA(MapleJob.DAWNWARRIOR1) || player.getJob().isA(MapleJob.ARAN1)) { 
                
    MaxMP += 2
            } else if (
    player.getJob().isA(MapleJob.MAGICIAN) || player.getJob().isA(MapleJob.BLAZEWIZARD1)) { 
                if (
    player.getSkillLevel(player.isCygnus() ? SkillFactory.getSkill(12000000) : SkillFactory.getSkill(2000001)) > 0) { 
                    
    MaxMP += 18
                } else { 
                    
    MaxMP += 14
                } 

            } else if (
    player.getJob().isA(MapleJob.BOWMAN) || player.getJob().isA(MapleJob.THIEF)) { 
                
    MaxMP += 10
            } else if (
    player.getJob().isA(MapleJob.PIRATE)) { 
                
    MaxMP += 14
            } 

            return 
    MaxMP
        } 

        public 
    void addSummon(int idMapleSummon summon) { 
            
    summons.put(idsummon); 
        } 

        public 
    void addVisibleMapObject(MapleMapObject mo) { 
            
    visibleMapObjects.add(mo); 
        } 

        public 
    void ban(String reason) { 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) { 
                    
    ps.setString(1reason); 
                    
    ps.setInt(2accountid); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    Exception e) { 
            } 

        } 

        public static 
    boolean ban(String idString reasonboolean accountId) { 
            
    PreparedStatement ps null
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                if (
    id.matches("/[0-9]{1,3}\\..*")) { 
                    
    ps con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)"); 
                    
    ps.setString(1id); 
                    
    ps.executeUpdate(); 
                    
    ps.close(); 
                    return 
    true
                } 
                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(1id); 
                try (
    ResultSet rs ps.executeQuery()) { 
                    if (
    rs.next()) { 
                        try (
    PreparedStatement psb DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) { 
                            
    psb.setString(1reason); 
                            
    psb.setInt(2rs.getInt(1)); 
                            
    psb.executeUpdate(); 
                        } 
                        
    ret true
                    } 
                } 
                
    ps.close(); 
                return 
    ret
            } catch (
    SQLException ex) { 
            } finally { 
                try { 
                    if (
    ps != null && !ps.isClosed()) { 
                        
    ps.close(); 
                    } 
                } catch (
    SQLException e) { 
                } 
            } 
            return 
    false
        } 

        public 
    int calculateMaxBaseDamage(int watk) { 
            
    int maxbasedamage
            if (
    watk == 0) { 
                
    maxbasedamage 1
            } else { 
                
    Item 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) || getJob().isA(MapleJob.NIGHTWALKER1)) && (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) + 10
                } else { 
                    
    maxbasedamage 0
                } 
            } 
            return 
    maxbasedamage
        } 

        public 
    void cancelAllBuffs(boolean disconnect) { 
            if (
    disconnect) { 
                
    effects.clear(); 
            } else { 
                for (
    MapleBuffStatValueHolder mbsvh : new ArrayList<>(effects.values())) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        public 
    void cancelBuffStats(MapleBuffStat stat) { 
            List<
    MapleBuffStatbuffStatList Arrays.asList(stat); 
            
    deregisterBuffStats(buffStatList); 
            
    cancelPlayerBuffs(buffStatList); 
        } 

        public 
    void setCombo(short count) { 
            if (
    count combocounter) { 
                
    cancelEffectFromBuffStat(MapleBuffStat.ARAN_COMBO); 
            } 
            
    combocounter = (shortMath.min(30000count); 
            if (
    count 0) { 
                
    announce(MaplePacketCreator.showCombo(combocounter)); 
            } 
        } 

        public 
    void setLastCombo(long time) { 
            ; 
            
    lastcombo time
        } 

        public 
    short getCombo() { 
            return 
    combocounter
        } 

        public 
    long getLastCombo() { 
            return 
    lastcombo
        } 

        public 
    int getLastMobCount() { // Used for skills that have mobCount at 1. (a/b) 
            
    return lastmobcount
        } 

        public 
    void setLastMobCount(byte count) { 
            
    lastmobcount count
        } 

        public 
    void newClient(MapleClient c) { 
            
    this.loggedIn true
            
    c.setAccountName(this.client.getAccountName());// No null's for accountName 
            
    this.client c
            
    MaplePortal portal map.findClosestSpawnpoint(getPosition()); 
            if (
    portal == null) { 
                
    portal map.getPortal(0); 
            } 
            
    this.setPosition(portal.getPosition()); 
            
    this.initialSpawnPoint portal.getId(); 
            
    this.map c.getChannelServer().getMapFactory().getMap(getMapId()); 
        } 

        public 
    void cancelBuffEffects() { 
            for (
    MapleBuffStatValueHolder mbsvh effects.values()) { 
                if (
    mbsvh.schedule != null
                    
    mbsvh.schedule.cancel(false); 
            } 
            
    this.effects.clear(); 
        } 

        public 
    String getMedalText() { 
            
    String medal ""
            final 
    Item medalItem getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -49); 
            if (
    medalItem != null) { 
                
    medal "<" MapleItemInformationProvider.getInstance().getName(medalItem.getItemId()) + "> "
            } 
            return 
    medal
        } 
             
            public 
    void giftMedal(int id) { 
            if (!
    this.getInventory(MapleInventoryType.EQUIP).isFull() && ServerConstants.gain_medals == true && this.getInventory(MapleInventoryType.EQUIP).countById(id) == && this.getInventory(MapleInventoryType.EQUIPPED).countById(id) == 0) { 
             
    MapleInventoryManipulator.addById(clientid,(short1); 
             
    client.announce(MaplePacketCreator.earnTitleMessage("#eYou have just gained an #b" MapleItemInformationProvider.getInstance().getName(id) + "#k! Congrats!")); 
             
    dropMessage("You have just gained an " MapleItemInformationProvider.getInstance().getName(id) + "! Congrats!"); 
            } else if (
    ServerConstants.gain_medals == true && this.getInventory(MapleInventoryType.EQUIP).countById(id) == && this.getInventory(MapleInventoryType.EQUIPPED).countById(id) == 0) { 
             
    MapleInventoryManipulator.drop(clientMapleInventoryType.EQUIP,(byte1, (byte1); 
             
    MapleInventoryManipulator.addById(clientid,(short1); 
             
    client.announce(MaplePacketCreator.earnTitleMessage("#eYou have just gained an #b" MapleItemInformationProvider.getInstance().getName(id) + "#k! Congrats!")); 
             
    dropMessage("You have just gained an " MapleItemInformationProvider.getInstance().getName(id) + "! Congrats!"); 
            } 
        } 
             
            public 
    void setExpBonuses(int amt) { 
        
    this.expbonuses=amt
        } 

        public 
    void addExpBonus() { 
            
    setExpBonuses(this.expbonuses+1); 
            
    dropMessage(ServerConstants.exp_bonus_message); 
            
    client.announce(MaplePacketCreator.earnTitleMessage(ServerConstants.exp_bonus_overhead_message)); 
        } 

        public 
    int getExpBonuses() { 
            return 
    expbonuses
        } 

        public 
    int getHorntailSlyed() { 
            return 
    horntail_slyed
        } 

        public 
    int getPinkBeenSlyed() { 
            return 
    pinkbeen_slyed
        } 

        public 
    void setHorntailSlyed(int set) { 
            
    this.horntail_slyed set
        } 

        public 
    void setPinkBeenSlyed(int set) { 
            
    this.pinkbeen_slyed set
        } 

        public 
    void gainHorntailSlyed(int gain) { 
            
    setHorntailSlyed(getHorntailSlyed() + gain); 
        } 

        public 
    void gainPinkBeenSlyed(int gain) { 
            
    setPinkBeenSlyed(getPinkBeenSlyed() + gain); 
        } 

        public 
    int getLegendById() { 
            return 
    legend
        } 
        public 
    String Legend() { 
            if (
    legend == 1) { 
                return 
    "GameMaster"
            } else if (
    legend == 2) { 
                return 
    "Beginner"
            } else if (
    legend == 3) { 
                return 
    "PartyQuestsMania"
            } else if (
    legend == 4) { 
                return 
    "QuestSpecialists"
            } else if (
    legend == 5) { 
                return 
    "SuperHunter"
            } else if (
    legend == 6) { 
                return 
    "King"
            } else if (
    legend == 7) { 
                return 
    "Devil"
            } else if (
    legend == 8) { 
                return 
    "Genius"
            } else if (
    legend == 9) { 
                return 
    "Ninja"
            } else if (
    legend == 10) { 
                return 
    "Sea King"
            } else if (
    legend == 11) { 
                return 
    "Fame Star"
            } else if (
    legend == 12) { 
                return 
    "Maple Idle Star"
            } else if (
    legend == 13) { 
                return 
    "Horntail Slayer"
            } else if (
    legend == 14) { 
                return 
    "Pinkbeen Slayer"
            } else if (
    legend == 15) { 
                return 
    "Rebirth Power man"
            } else if (
    legend == 16) { 
                return 
    "Loss King"
            } else if (
    legend == 17) { 
                return 
    "Win King"
            } else if (
    legend == 18) { 
                return 
    "Romeo"
            } else if (
    legend == 19) { 
                return 
    "Juliet"
            } else if (
    legend == 20) { 
                return 
    "VIPPER"
            } else if (
    legend == 21) { 
                return 
    "Rebirth King"
            } else { 
                return 
    null
            } 
        } 

        public 
    String getLegend() { 
            if (
    legend != 0) { 
                return 
    "<" Legend() + "> "
            } else { 
                return 
    ""
            } 
        } 

        public 
    void setlegend(int legendid) { 
            
    this.legend legendid
        } 

        public static class 
    CancelCooldownAction implements Runnable 

            private 
    int skillId
            private 
    WeakReference<MapleCharactertarget

            public 
    CancelCooldownAction(MapleCharacter targetint skillId) { 
                
    this.target = new WeakReference<>(target); 
                
    this.skillId skillId
            } 

           [
    MENTION=2000004426]Override[/MENTION
            public 
    void run() { 
                
    MapleCharacter realTarget target.get(); 
                if (
    realTarget != null) { 
                    
    realTarget.removeCooldown(skillId); 
                    
    realTarget.client.announce(MaplePacketCreator.skillCooldown(skillId0)); 
                } 
            } 
        } 

        public 
    void cancelEffect(int itemId) { 
            
    cancelEffect(MapleItemInformationProvider.getInstance().getItemEffect(itemId), false, -1); 
        } 

        public 
    void cancelEffect(MapleStatEffect effectboolean overwritelong startTime) { 
            List<
    MapleBuffStatbuffstats
            if (!
    overwrite) { 
                
    buffstats getBuffStats(effectstartTime); 
            } else { 
                List<
    Pair<MapleBuffStatInteger>> statups effect.getStatups(); 
                
    buffstats = new ArrayList<>(statups.size()); 
                for (
    Pair<MapleBuffStatIntegerstatup statups) { 
                    
    buffstats.add(statup.getLeft()); 
                } 
            } 
            
    deregisterBuffStats(buffstats); 
            if (
    effect.isMagicDoor()) { 
                if (!
    getDoors().isEmpty()) { 
                    
    MapleDoor door getDoors().iterator().next(); 
                    for (
    MapleCharacter chr door.getTarget().getCharacters()) { 
                        
    door.sendDestroyData(chr.client); 
                    } 
                    for (
    MapleCharacter chr door.getTown().getCharacters()) { 
                        
    door.sendDestroyData(chr.client); 
                    } 
                    for (
    MapleDoor destroyDoor getDoors()) { 
                        
    door.getTarget().removeMapObject(destroyDoor); 
                        
    door.getTown().removeMapObject(destroyDoor); 
                    } 
                    
    clearDoors(); 
                    
    silentPartyUpdate(); 
                } 
            } 
            if (
    effect.getSourceId() == Spearman.HYPER_BODY || effect.getSourceId() == GM.HYPER_BODY || effect.getSourceId() == SuperGM.HYPER_BODY) { 
                List<
    Pair<MapleStatInteger>> statup = new ArrayList<>(4); 
                
    statup.add(new Pair<>(MapleStat.HPMath.min(hpmaxhp))); 
                
    statup.add(new Pair<>(MapleStat.MPMath.min(mpmaxmp))); 
                
    statup.add(new Pair<>(MapleStat.MAXHPmaxhp)); 
                
    statup.add(new Pair<>(MapleStat.MAXMPmaxmp)); 
                
    client.announce(MaplePacketCreator.updatePlayerStats(statup)); 
            } 
            if (
    effect.isMonsterRiding()) { 
                if (
    effect.getSourceId() != Corsair.BATTLE_SHIP) { 
                    
    this.getMount().cancelSchedule(); 
                    
    this.getMount().setActive(false); 
                } 
            } 
            if (!
    overwrite) { 
                
    cancelPlayerBuffs(buffstats); 
            } 
        } 

        public 
    void cancelEffectFromBuffStat(MapleBuffStat stat) { 
            
    MapleBuffStatValueHolder effect effects.get(stat); 
            if (
    effect != null) { 
                
    cancelEffect(effect.effectfalse, -1); 
            } 
        } 

        public 
    void Hide(boolean hideboolean login) { 
            if (
    isGM() && hide != this.hidden) { 
                if (!
    hide) { 
                    
    this.hidden false
                    
    announce(MaplePacketCreator.getGMEffect(0x10, (byte0)); 
                    
    getMap().broadcastMessage(thisMaplePacketCreator.spawnPlayerMapobject(this), false); 
                    
    updatePartyMemberHP(); 
                } else { 
                    
    this.hidden true
                    
    announce(MaplePacketCreator.getGMEffect(0x10, (byte1)); 
                    if (!
    login) { 
                        
    getMap().broadcastMessage(thisMaplePacketCreator.removePlayerFromMap(getId()), false); 
                    } 
                } 
                
    announce(MaplePacketCreator.enableActions()); 
            } 
        } 

        public 
    void Hide(boolean hide) { 
            
    Hide(hidefalse); 
        } 

        public 
    void toggleHide(boolean login) { 
            
    Hide(!isHidden()); 
        } 

        private 
    void cancelFullnessSchedule(int petSlot) { 
            if (
    fullnessSchedule[petSlot] != null) { 
                
    fullnessSchedule[petSlot].cancel(false); 
            } 
        } 

        public 
    void cancelMagicDoor() { 
            for (
    MapleBuffStatValueHolder mbsvh : new ArrayList<>(effects.values())) { 
                if (
    mbsvh.effect.isMagicDoor()) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        public 
    void cancelMapTimeLimitTask() { 
            if (
    mapTimeLimitTask != null) { 
                
    mapTimeLimitTask.cancel(false); 
            } 
        } 

        private 
    void cancelPlayerBuffs(List<MapleBuffStatbuffstats) { 
            if (
    client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null) { 
                
    recalcLocalStats(); 
                
    enforceMaxHpMp(); 
                
    client.announce(MaplePacketCreator.cancelBuff(buffstats)); 
                if (
    buffstats.size() > 0) { 
                    
    getMap().broadcastMessage(thisMaplePacketCreator.cancelForeignBuff(getId(), buffstats), false); 
                } 
            } 
        } 

        public static 
    boolean canCreateChar(String name) { 
            if (
    name.length() < || name.length() > 12) { 
                return 
    false
            } 

            if (
    isInUse(name)) { 
                return 
    false
            } 

            return 
    getIdByName(name) < && !name.toLowerCase().contains("gm") && Pattern.compile("[a-zA-Z0-9_-]{3,12}").matcher(name).matches(); 
        } 

        public 
    boolean canDoor() { 
            return 
    canDoor
        } 

        public 
    FameStatus canGiveFame(MapleCharacter from) { 
            if (
    gmLevel 0) { 
                return 
    FameStatus.OK
            } else if (
    lastfametime >= System.currentTimeMillis() - 3600000 24) { 
                return 
    FameStatus.NOT_TODAY
            } else if (
    lastmonthfameids.contains(Integer.valueOf(from.getId()))) { 
                return 
    FameStatus.NOT_THIS_MONTH
            } else { 
                return 
    FameStatus.OK
            } 
        } 

        public 
    void changeCI(int type) { 
            
    this.ci type
        } 

        public 
    void changeJob(int id) { 
            
    changeJob(MapleJob.getById(id)); 
        } 
             
            public 
    void jobChangingMedalCheck() { 
            if (
    this.getJob().getId() == 100 || this.getJob().getId() == 200 || this.getJob().getId() == 300 || this.getJob().getId() == 400 || this.getJob().getId() == 500) { 
            
    giftMedal(1142107); //adventurer 
            

            if (
    this.getJob().getId() == 110 || this.getJob().getId() == 120 || this.getJob().getId() == 130 || this.getJob().getId() == 210 || this.getJob().getId() == 220 || this.getJob().getId() == 230 || this.getJob().getId() == 310 || this.getJob().getId() == 320 || this.getJob().getId() == 410 || this.getJob().getId() == 420 || this.getJob().getId() == 510 || this.getJob().getId() == 520) { 
            
    giftMedal(1142108);//Jr. adventurer 
            

            if (
    this.getJob().getId() == 111 || this.getJob().getId() == 121 || this.getJob().getId() == 131 || this.getJob().getId() == 211 || this.getJob().getId() == 221 || this.getJob().getId() == 231 || this.getJob().getId() == 311 || this.getJob().getId() == 321 || this.getJob().getId() == 411 || this.getJob().getId() == 421 || this.getJob().getId() == 511 || this.getJob().getId() == 521) { 
            
    giftMedal(1142109); // veteran adv! 
            

            if (
    this.getJob().getId() == 112 || this.getJob().getId() == 122 || this.getJob().getId() == 1322 || this.getJob().getId() == 212 || this.getJob().getId() == 222 || this.getJob().getId() == 232 || this.getJob().getId() == 311 || this.getJob().getId() == 322 || this.getJob().getId() == 412 || this.getJob().getId() == 422 || this.getJob().getId() == 512 || this.getJob().getId() == 522) { 
            
    giftMedal(1142110); // master adv! 
            

            if (
    this.getJob().getId() == 1100 || this.getJob().getId() == 1200 || this.getJob().getId() == 1300 || this.getJob().getId() == 1400 || this.getJob().getId() == 1500) { 
            
    giftMedal(1142066); // training knight 
            

            if (
    this.getJob().getId() == 1110 || this.getJob().getId() == 1210 || this.getJob().getId() == 1310 || this.getJob().getId() == 1410 || this.getJob().getId() == 1510) { 
            
    giftMedal(1142067); // official knight 
            

            if (
    this.getJob().getId() == 1111 || this.getJob().getId() == 1211 || this.getJob().getId() == 1311 || this.getJob().getId() == 1411 || this.getJob().getId() == 1511) { 
            
    giftMedal(1142068); // advanced knight 
            

            if (
    this.getJob().getId() == 1112 || this.getJob().getId() == 1212 || this.getJob().getId() == 1312 || this.getJob().getId() == 1412 || this.getJob().getId() == 1512) { 
            
    giftMedal(1142069); // captain knight 
            

            if (
    this.getJob().getId() == 2100) { 
              
    giftMedal(1142129);  //aran1 
            

            if (
    this.getJob().getId() == 2110) { 
              
    giftMedal(1142130);  //aran2 
            

            if (
    this.getJob().getId() == 2111) { 
              
    giftMedal(1142131);  //aran3 
            

            if (
    this.getJob().getId() == 2112) { 
              
    giftMedal(1142132);  //aran4 
            

        } 

        public 
    void changeJob(MapleJob newJob) { 
            if (
    newJob == null) { 
                return;
    // the fuck you doing idiot! 
            

            
    this.job newJob
            
    this.remainingSp++; 
            if (
    newJob.getId() % 10 == 2) { 
                
    this.remainingSp += 2
            } 
            if (
    newJob.getId() % 10 1) { 
                
    this.remainingAp += 5
            } 
            
    int job_ job.getId() % 1000// lame temp "fix" 
            
    if (job_ == 100) { 
                
    maxhp += Randomizer.next(200250); 
            } else if (
    job_ == 200) { 
                
    maxmp += Randomizer.next(100150); 
            } else if (
    job_ 100 == 0) { 
                
    maxhp += Randomizer.next(100150); 
                
    maxhp += Randomizer.next(2550); 
            } else if (
    job_ && job_ 200) { 
                
    maxhp += Randomizer.next(300350); 
            } else if (
    job_ 300) { 
                
    maxmp += Randomizer.next(450500); 
            } 
    // handle KoC here (undone) 
            
    else if (job_ && job_ != 1000) { 
                
    maxhp += Randomizer.next(300350); 
                
    maxmp += Randomizer.next(150200); 
            } 
            if (
    maxhp >= 30000) { 
                
    maxhp 30000
            } 
            if (
    maxmp >= 30000) { 
                
    maxmp 30000
            } 

            List<
    Pair<MapleStatInteger>> statup = new ArrayList<>(5); 
            
    statup.add(new Pair<>(MapleStat.MAXHPInteger.valueOf(maxhp))); 
            
    statup.add(new Pair<>(MapleStat.MAXMPInteger.valueOf(maxmp))); 
            
    statup.add(new Pair<>(MapleStat.AVAILABLEAPremainingAp)); 
            
    statup.add(new Pair<>(MapleStat.AVAILABLESPremainingSp)); 
            
    statup.add(new Pair<>(MapleStat.JOBInteger.valueOf(job.getId()))); 
            
    recalcLocalStats(); 
            
    client.announce(MaplePacketCreator.updatePlayerStats(statup)); 

            
    silentPartyUpdate(); 
            if (
    this.guildid 0) { 
                
    getGuild().broadcast(MaplePacketCreator.jobMessage(0job.getId(), name), this.getId()); 
            } 
            
    guildUpdate(); 
            
    getMap().broadcastMessage(thisMaplePacketCreator.showForeignEffect(getId(), 8), false); 
        } 

        public 
    void changeKeybinding(int keyMapleKeyBinding keybinding) { 
            if (
    keybinding.getType() != 0) { 
                
    keymap.put(Integer.valueOf(key), keybinding); 
            } else { 
                
    keymap.remove(Integer.valueOf(key)); 
            } 
        } 

        public 
    void changeMap(int map) { 
            
    changeMap(map0); 
        } 

        public 
    void changeMap(int mapint portal) { 
            
    MapleMap warpMap client.getChannelServer().getMapFactory().getMap(map); 
            
    changeMap(warpMapwarpMap.getPortal(portal)); 
        } 

        public 
    void changeMap(int mapString portal) { 
            
    MapleMap warpMap client.getChannelServer().getMapFactory().getMap(map); 
            
    changeMap(warpMapwarpMap.getPortal(portal)); 
        } 

        public 
    void changeMap(int mapMaplePortal portal) { 
            
    MapleMap warpMap client.getChannelServer().getMapFactory().getMap(map); 
            
    changeMap(warpMapportal); 
        } 

        public 
    void changeMap(MapleMap to) { 
            
    changeMap(toto.getPortal(0)); 
        } 

        public 
    void changeMap(final MapleMap to, final MaplePortal pto) { 
            
    changeMapInternal(topto.getPosition(), MaplePacketCreator.getWarpToMap(topto.getId(), this)); 
        } 

        public 
    void changeMap(final MapleMap to, final Point pos) { 
            
    changeMapInternal(toposMaplePacketCreator.getWarpToMap(to0x80this));// Position :O (LEFT) 
        


        public 
    void changeMapBanish(int mapidString portalString msg) { 
            
    dropMessage(5msg); 
            
    MapleMap map_ client.getChannelServer().getMapFactory().getMap(mapid); 
            
    changeMap(map_map_.getPortal(portal)); 
        } 

        private 
    void changeMapInternal(final MapleMap to, final Point pos, final byte[] warpPacket) { 
            
    client.announce(warpPacket); 
            
    map.removePlayer(MapleCharacter.this); 
            if (
    client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null) { 
                
    map to
                
    setPosition(pos); 
                
    map.addPlayer(MapleCharacter.this); 
                if (
    party != null) { 
                    
    mpc.setMapId(to.getId()); 
                    
    silentPartyUpdate(); 
                    
    client.announce(MaplePacketCreator.updateParty(client.getChannel(), partyPartyOperation.SILENT_UPDATEnull)); 
                    
    updatePartyMemberHP(); 
                } 
                if (
    getMap().getHPDec() > 0) { 
                    
    hpDecreaseTask TimerManager.getInstance().schedule(new Runnable() { 
                       [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    doHurtHp(); 
                        } 
                    }, 
    10000); 
                } 
            } 
        } 

        public 
    void changePage(int page) { 
            
    this.currentPage page
        } 

        public 
    void changeSkillLevel(Skill skillbyte newLevelint newMasterlevellong expiration) { 
            if (
    newLevel > -1) { 
                
    skills.put(skill, new SkillEntry(newLevelnewMasterlevelexpiration)); 
                
    this.client.announce(MaplePacketCreator.updateSkill(skill.getId(), newLevelnewMasterlevelexpiration)); 
            } else { 
                
    skills.remove(skill); 
                
    this.client.announce(MaplePacketCreator.updateSkill(skill.getId(), newLevelnewMasterlevel, -1)); // Shouldn't use expiration anymore :) 
                
    try { 
                    
    Connection con DatabaseConnection.getConnection(); 
                    try (
    PreparedStatement ps con.prepareStatement("DELETE FROM skills WHERE skillid = ? AND characterid = ?")) {
                        
    ps.setInt(1skill.getId()); 
                        
    ps.setInt(2id); 
                        
    ps.execute(); 
                    } 
                } catch (
    SQLException ex) { 
                    
    System.out.print("Error deleting skill: " ex); 
                } 
            } 
        } 

        public 
    void changeTab(int tab) { 
            
    this.currentTab tab
        } 

        public 
    void changeType(int type) { 
            
    this.currentType type
        } 

        public 
    void checkBerserk() { 
            if (
    BerserkSchedule != null) { 
                
    BerserkSchedule.cancel(false); 
            } 
            final 
    MapleCharacter chr this
            if (
    job.equals(MapleJob.DARKKNIGHT)) { 
                
    Skill BerserkX SkillFactory.getSkill(DarkKnight.BERSERK); 
                final 
    int skilllevel getSkillLevel(BerserkX); 
                if (
    skilllevel 0) { 
                    
    Berserk chr.getHp() * 100 chr.getMaxHp() < BerserkX.getEffect(skilllevel).getX(); 
                    
    BerserkSchedule TimerManager.getInstance().register(new Runnable() { 
                       [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    client.announce(MaplePacketCreator.showOwnBerserk(skilllevelBerserk)); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showBerserk(getId(), skilllevelBerserk), false); 
                        } 
                    }, 
    50003000); 
                } 
            } 
        } 

        public 
    void checkMessenger() { 
            if (
    messenger != null && messengerposition && messengerposition > -1) { 
                
    World worldz Server.getInstance().getWorld(world); 
                
    worldz.silentJoinMessenger(messenger.getId(), new MapleMessengerCharacter(thismessengerposition), messengerposition); 
                
    worldz.updateMessenger(getMessenger().getId(), nameclient.getChannel()); 
            } 
        } 

        public 
    void checkMonsterAggro(MapleMonster monster) { 
            if (!
    monster.isControllerHasAggro()) { 
                if (
    monster.getController() == this) { 
                    
    monster.setControllerHasAggro(true); 
                } else { 
                    
    monster.switchController(thistrue); 
                } 
            } 
        } 

        public 
    void clearDoors() { 
            
    doors.clear(); 
        } 

        public 
    void clearSavedLocation(SavedLocationType type) { 
            
    savedLocations[type.ordinal()] = null
        } 

        public 
    void controlMonster(MapleMonster monsterboolean aggro) { 
            
    monster.setController(this); 
            
    controlled.add(monster); 
            
    client.announce(MaplePacketCreator.controlMonster(monsterfalseaggro)); 
        } 

        public 
    int countItem(int itemid) { 
            return 
    inventory[MapleItemInformationProvider.getInstance().getInventoryType(itemid).ordinal()].countById(itemid); 
        } 

        public 
    void decreaseBattleshipHp(int decrease) { 
            
    this.battleshipHp -= decrease
            if (
    battleshipHp <= 0) { 
                
    this.battleshipHp 0
                
    Skill battleship SkillFactory.getSkill(Corsair.BATTLE_SHIP); 
                
    int cooldown battleship.getEffect(getSkillLevel(battleship)).getCooldown(); 
                
    announce(MaplePacketCreator.skillCooldown(Corsair.BATTLE_SHIPcooldown)); 
                
    addCooldown(Corsair.BATTLE_SHIPSystem.currentTimeMillis(), cooldownTimerManager.getInstance().schedule(new CancelCooldownAction(thisCorsair.BATTLE_SHIP), cooldown 1000)); 
                
    removeCooldown(5221999); 
                
    cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING); 
            } else { 
                
    announce(MaplePacketCreator.skillCooldown(5221999battleshipHp 10)); // :D 
                
    addCooldown(52219990battleshipHpnull); 
            } 
        } 

        public 
    void decreaseReports() { 
            
    this.possibleReports--; 
        } 

        public 
    void deleteGuild(int guildId) { 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE characters SET guildid = 0, guildrank = 5 WHERE guildid = ?")) { 
                    
    ps.setInt(1guildId); 
                    
    ps.execute(); 
                } 
                try (
    PreparedStatement ps con.prepareStatement("DELETE FROM guilds WHERE guildid = ?")) { 
                    
    ps.setInt(1id); 
                    
    ps.execute(); 
                } 
            } catch (
    SQLException ex) { 
                
    System.out.print("Error deleting guild: " ex); 
            } 
        } 

        private 
    void deleteWhereCharacterId(Connection conString sqlthrows SQLException 
            try (
    PreparedStatement ps con.prepareStatement(sql)) { 
                
    ps.setInt(1id); 
                
    ps.executeUpdate(); 
            } 
        } 

        public static 
    void deleteWhereCharacterId(Connection conString sqlint cidthrows SQLException 
            try (
    PreparedStatement ps con.prepareStatement(sql)) { 
                
    ps.setInt(1cid); 
                
    ps.executeUpdate(); 
            } 
        } 

        private 
    void deregisterBuffStats(List<MapleBuffStatstats) { 
            
    synchronized (stats) { 
                List<
    MapleBuffStatValueHoldereffectsToCancel = new ArrayList<>(stats.size()); 
                for (
    MapleBuffStat stat stats) { 
                    
    MapleBuffStatValueHolder mbsvh effects.get(stat); 
                    if (
    mbsvh != null) { 
                        
    effects.remove(stat); 
                        
    boolean addMbsvh true
                        for (
    MapleBuffStatValueHolder contained effectsToCancel) { 
                            if (
    mbsvh.startTime == contained.startTime && contained.effect == mbsvh.effect) { 
                                
    addMbsvh false
                            } 
                        } 
                        if (
    addMbsvh) { 
                            
    effectsToCancel.add(mbsvh); 
                        } 
                        if (
    stat == MapleBuffStat.RECOVERY) { 
                            if (
    recoveryTask != null) { 
                                
    recoveryTask.cancel(false); 
                                
    recoveryTask null
                            } 
                        } else if (
    stat == MapleBuffStat.SUMMON || stat == MapleBuffStat.PUPPET) { 
                            
    int summonId mbsvh.effect.getSourceId(); 
                            
    MapleSummon summon summons.get(summonId); 
                            if (
    summon != null) { 
                                
    getMap().broadcastMessage(MaplePacketCreator.removeSummon(summontrue), summon.getPosition()); 
                                
    getMap().removeMapObject(summon); 
                                
    removeVisibleMapObject(summon); 
                                
    summons.remove(summonId); 
                            } 
                            if (
    summon.getSkill() == DarkKnight.BEHOLDER) { 
                                if (
    beholderHealingSchedule != null) { 
                                    
    beholderHealingSchedule.cancel(false); 
                                    
    beholderHealingSchedule null
                                } 
                                if (
    beholderBuffSchedule != null) { 
                                    
    beholderBuffSchedule.cancel(false); 
                                    
    beholderBuffSchedule null
                                } 
                            } 
                        } else if (
    stat == MapleBuffStat.DRAGONBLOOD) { 
                            
    dragonBloodSchedule.cancel(false); 
                            
    dragonBloodSchedule null
                        } 
                    } 
                } 
                for (
    MapleBuffStatValueHolder cancelEffectCancelTasks effectsToCancel) { 
                    if (
    cancelEffectCancelTasks.schedule != null) { 
                        
    cancelEffectCancelTasks.schedule.cancel(false); 
                    } 
                } 
            } 
        } 

        public 
    void disableDoor() { 
            
    canDoor false
            
    TimerManager.getInstance().schedule(new Runnable() { 
               [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    canDoor true
                } 
            }, 
    5000); 
        } 

        public 
    void disbandGuild() { 
            if (
    guildid || guildrank != 1) { 
                return; 
            } 
            try { 
                
    Server.getInstance().disbandGuild(guildid); 
            } catch (
    Exception e) { 
            } 
        } 

        public 
    void dispel() { 
            for (
    MapleBuffStatValueHolder mbsvh : new ArrayList<>(effects.values())) { 
                if (
    mbsvh.effect.isSkill()) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        public final List<
    PlayerDiseaseValueHoldergetAllDiseases() { 
            final List<
    PlayerDiseaseValueHolderret = new ArrayList<>(5); 

            
    DiseaseValueHolder vh
            for (
    Entry<MapleDiseaseDiseaseValueHolderdisease diseases.entrySet()) { 
                
    vh disease.getValue(); 
                
    ret.add(new PlayerDiseaseValueHolder(disease.getKey(), vh.startTimevh.length)); 
            } 
            return 
    ret
        } 

        public final 
    boolean hasDisease(final MapleDisease dis) { 
            for (final 
    MapleDisease disease diseases.keySet()) { 
                if (
    disease == dis) { 
                    return 
    true
                } 
            } 
            return 
    false
        } 

        public 
    void giveDebuff(final MapleDisease diseaseMobSkill skill) { 
            final List<
    Pair<MapleDiseaseInteger>> debuff Collections.singletonList(new Pair<>(diseaseInteger.valueOf(skill.getX()))); 

            if (!
    hasDisease(disease) && diseases.size() < 2) { 
                if (!(
    disease == MapleDisease.SEDUCE || disease == MapleDisease.STUN)) { 
                    if (
    isActiveBuffedValue(2321005)) { 
                        return; 
                    } 
                } 
                
    TimerManager.getInstance().schedule(new Runnable() { 
                   [
    MENTION=2000004426]Override[/MENTION
                    public 
    void run() { 
                        
    dispelDebuff(disease); 
                    } 
                }, 
    skill.getDuration()); 

                
    diseases.put(disease, new DiseaseValueHolder(System.currentTimeMillis(), skill.getDuration())); 
                
    client.announce(MaplePacketCreator.giveDebuff(debuffskill)); 
                
    map.broadcastMessage(thisMaplePacketCreator.giveForeignDebuff(iddebuffskill), false); 
            } 
        } 

        public 
    void dispelDebuff(MapleDisease debuff) { 
            if (
    hasDisease(debuff)) { 
                
    long mask debuff.getValue(); 
                
    announce(MaplePacketCreator.cancelDebuff(mask)); 
                
    map.broadcastMessage(thisMaplePacketCreator.cancelForeignDebuff(idmask), false); 

                
    diseases.remove(debuff); 
            } 
        } 

        public 
    void dispelDebuffs() { 
            
    dispelDebuff(MapleDisease.CURSE); 
            
    dispelDebuff(MapleDisease.DARKNESS); 
            
    dispelDebuff(MapleDisease.POISON); 
            
    dispelDebuff(MapleDisease.SEAL); 
            
    dispelDebuff(MapleDisease.WEAKEN); 
        } 

        public 
    void cancelAllDebuffs() { 
            
    diseases.clear(); 
        } 

        public 
    void dispelSkill(int skillid) { 
            
    LinkedList<MapleBuffStatValueHolderallBuffs = new LinkedList<>(effects.values()); 
            for (
    MapleBuffStatValueHolder mbsvh allBuffs) { 
                if (
    skillid == 0) { 
                    if (
    mbsvh.effect.isSkill() && (mbsvh.effect.getSourceId() % 10000000 == 1004 || dispelSkills(mbsvh.effect.getSourceId()))) { 
                        
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                    } 
                } else if (
    mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        private 
    boolean dispelSkills(int skillid) { 
            switch (
    skillid) { 
                case 
    DarkKnight.BEHOLDER
                case 
    FPArchMage.ELQUINES
                case 
    ILArchMage.IFRIT
                case 
    Priest.SUMMON_DRAGON
                case 
    Bishop.BAHAMUT
                case 
    Ranger.PUPPET
                case 
    Ranger.SILVER_HAWK
                case 
    Sniper.PUPPET
                case 
    Sniper.GOLDEN_EAGLE
                case 
    Hermit.SHADOW_PARTNER
                    return 
    true
                default: 
                    return 
    false
            } 
        } 

        public 
    void doHurtHp() { 
            if (
    this.getInventory(MapleInventoryType.EQUIPPED).findById(getMap().getHPDecProtect()) != null) { 
                return; 
            } 
            
    addHP(-getMap().getHPDec()); 
            
    hpDecreaseTask TimerManager.getInstance().schedule(new Runnable() { 
               [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    doHurtHp(); 
                } 
            }, 
    10000); 
        } 

        public 
    void dropMessage(String message) { 
            
    dropMessage(6message); 
        } 

        public 
    void dropMessage(int typeString message) { 
            if (
    type == -1) { // like in the later versions :D 
                
    client.announce(MaplePacketCreator.earnTitleMessage(message)); 
                return; 
            } 
            
    client.announce(MaplePacketCreator.serverNotice(typemessage)); 
        } 

        public 
    String emblemCost() { 
            return 
    nf.format(MapleGuild.CHANGE_EMBLEM_COST); 
        } 

        public List<
    ScheduledFuture<?>> getTimers() { 
            return timers; 
        } 

        private void enforceMaxHpMp() { 
            List<Pair<MapleStat, Integer>> stats = new ArrayList<>(2); 
            if (getMp() > getCurrentMaxMp()) { 
                setMp(getMp()); 
                stats.add(new Pair<>(MapleStat.MP, Integer.valueOf(getMp()))); 
            } 
            if (getHp() > getCurrentMaxHp()) { 
                setHp(getHp()); 
                stats.add(new Pair<>(MapleStat.HP, Integer.valueOf(getHp()))); 
            } 
            if (stats.size() > 0) { 
                client.announce(MaplePacketCreator.updatePlayerStats(stats)); 
            } 
        } 

        public void enteredScript(String script, int mapid) { 
            if (!entered.containsKey(mapid)) { 
                entered.put(mapid, script); 
            } 
        } 

        public void equipChanged() { 
            getMap().broadcastMessage(this, MaplePacketCreator.updateCharLook(this), false); 
            recalcLocalStats(); 
            enforceMaxHpMp(); 
            if (getMessenger() != null) { 
                Server.getInstance().getWorld(world).updateMessenger(getMessenger(), getName(), getWorld(), client.getChannel()); 
            } 
        } 

        public void cancelExpirationTask() { 
            if (expiretask != null) { 
                expiretask.cancel(false); 
                expiretask = null; 
            } 
        } 

        public void expirationTask() { 
            if (expiretask == null) { 
                expiretask = TimerManager.getInstance().register(new Runnable() { 
                   [MENTION=2000004426]Override[/MENTION] 
                    public void run() { 
                        long expiration, currenttime = System.currentTimeMillis(); 
                        Set<Skill> keys = getSkills().keySet(); 
                        for (Iterator<Skill> i = keys.iterator(); i.hasNext();) { 
                            Skill key = i.next(); 
                            SkillEntry skill = getSkills().get(key); 
                            if (skill.expiration != -1 && skill.expiration < currenttime) { 
                                changeSkillLevel(key, (byte) -1, 0, -1); 
                            } 
                        } 

                        List<Item> toberemove = new ArrayList<>(); 
                        for (MapleInventory inv : inventory) { 
                            for (Item item : inv.list()) { 
                                expiration = item.getExpiration(); 
                                if (expiration != -1 && (expiration < currenttime) && ((item.getFlag() & ItemConstants.LOCK) == ItemConstants.LOCK)) { 
                                    byte aids = item.getFlag(); 
                                    aids &= ~(ItemConstants.LOCK); 
                                    item.setFlag(aids); // Probably need a check, else people can make expiring items into permanent items... 
                                    item.setExpiration(-1); 
                                    forceUpdateItem(item); // TEST :3 
                                } else if (expiration != -1 && expiration < currenttime) { 
                                    client.announce(MaplePacketCreator.itemExpired(item.getItemId())); 
                                    toberemove.add(item); 
                                } 
                            } 
                            for (Item item : toberemove) { 
                                MapleInventoryManipulator.removeFromSlot(client, inv.getType(), item.getPosition(), item.getQuantity(), true); 
                            } 
                            toberemove.clear(); 
                        } 
                    } 
                }, 60000); 
            } 
        } 

        public enum FameStatus { 

            OK, 
            NOT_TODAY, 
            NOT_THIS_MONTH 
        } 

        public void forceUpdateItem(Item item) { 
            final List<ModifyInventory> mods = new LinkedList<>(); 
            mods.add(new ModifyInventory(3, item)); 
            mods.add(new ModifyInventory(0, item)); 
            client.announce(MaplePacketCreator.modifyInventory(true, mods)); 
        } 

        public void gainGachaExp() { 
            int expgain = 0; 
            int currentgexp = gachaexp.get(); 
            if ((currentgexp + exp.get()) >= ExpTable.getExpNeededForLevel(level)) { 
                expgain += ExpTable.getExpNeededForLevel(level) - exp.get(); 
                int nextneed = ExpTable.getExpNeededForLevel(level + 1); 
                if ((currentgexp - expgain) >= nextneed) { 
                    expgain += nextneed; 
                } 
                this.gachaexp.set(currentgexp - expgain); 
            } else { 
                expgain = this.gachaexp.getAndSet(0); 
            } 
            gainExp(expgain, false, false); 
            updateSingleStat(MapleStat.GACHAEXP, this.gachaexp.get()); 
        } 

        public void gainGachaExp(int gain) { 
            updateSingleStat(MapleStat.GACHAEXP, gachaexp.addAndGet(gain)); 
        } 

        public void gainExp(int gain, boolean show, boolean inChat) { 
            gainExp(gain, show, inChat, true); 
        } 

        public void gainExp(int gain, boolean show, boolean inChat, boolean white) { 
            int equip = (gain / 10) * pendantExp; 
            int total = gain + equip; 

            if (level < getMaxLevel()) { 
                if ((long) this.exp.get() + (long) total > (long) Integer.MAX_VALUE) { 
                    int gainFirst = ExpTable.getExpNeededForLevel(level) - this.exp.get(); 
                    total -= gainFirst + 1; 
                    this.gainExp(gainFirst + 1, false, inChat, white); 
                } 
                updateSingleStat(MapleStat.EXP, this.exp.addAndGet(total)); 
                if (show && gain != 0) { 
                    client.announce(MaplePacketCreator.getShowExpGain(gain, equip, inChat, white)); 
                } 

                while (exp.get() >= ExpTable.getExpNeededForLevel(level)) { 
                    levelUp(true); 
                } 
            } 
        } 

        public void gainFame(int delta) { 
            this.addFame(delta); 
            this.updateSingleStat(MapleStat.FAME, this.fame); 
        } 

        public void gainMeso(int gain, boolean show) { 
            gainMeso(gain, show, false, false); 
        } 

        public void gainMeso(int gain, boolean show, boolean enableActions, boolean inChat) { 
            if (meso.get() + gain < 0) { 
                client.announce(MaplePacketCreator.enableActions()); 
                return; 
            } 
            updateSingleStat(MapleStat.MESO, meso.addAndGet(gain), enableActions); 
            if (show) { 
                client.announce(MaplePacketCreator.getShowMesoGain(gain, inChat)); 
            } 
        } 

        public void genericGuildMessage(int code) { 
            this.client.announce(MaplePacketCreator.genericGuildMessage((byte) code)); 
        } 

        public int getAccountID() { 
            return accountid; 
        } 

        public List<PlayerBuffValueHolder> getAllBuffs() { 
            List<PlayerBuffValueHolder> ret = new ArrayList<>(); 
            for (MapleBuffStatValueHolder mbsvh : effects.values()) { 
                ret.add(new PlayerBuffValueHolder(mbsvh.startTime, mbsvh.effect)); 
            } 
            return ret; 
        } 

        public List<PlayerCoolDownValueHolder> getAllCooldowns() { 
            List<PlayerCoolDownValueHolder> ret = new ArrayList<>(); 
            for (MapleCoolDownValueHolder mcdvh : coolDowns.values()) { 
                ret.add(new PlayerCoolDownValueHolder(mcdvh.skillId, mcdvh.startTime, mcdvh.length)); 
            } 
            return ret; 
        } 

        public int getAllianceRank() { 
            return this.allianceRank; 
        } 

        public int getAllowWarpToId() { 
            return warpToId; 
        } 

        public static String getAriantRoomLeaderName(int room) { 
            return ariantroomleader[room]; 
        } 

        public static int getAriantSlotsRoom(int room) { 
            return ariantroomslot[room]; 
        } 

        public int getBattleshipHp() { 
            return battleshipHp; 
        } 

        public BuddyList getBuddylist() { 
            return buddylist; 
        } 

        public static Map<String, String> getCharacterFromDatabase(String name) { 
            Map<String, String> character = new LinkedHashMap<>(); 

            try { 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT `id`, `accountid`, `name` FROM `characters` WHERE `name` = ?")) { 
                    ps.setString(1, name); 
                    try (ResultSet rs = ps.executeQuery()) { 
                        if (!rs.next()) { 
                            rs.close(); 
                            ps.close(); 
                            return null; 
                        } 

                        for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { 
                            character.put(rs.getMetaData().getColumnLabel(i), rs.getString(i)); 
                        } 
                    } 
                } 
            } catch (SQLException sqle) { 
                sqle.printStackTrace(); 
            } 

            return character; 
        } 

        public static boolean isInUse(String name) { 
            return getCharacterFromDatabase(name) != null; 
        } 

        public Long getBuffedStarttime(MapleBuffStat effect) { 
            MapleBuffStatValueHolder mbsvh = effects.get(effect); 
            if (mbsvh == null) { 
                return null; 
            } 
            return Long.valueOf(mbsvh.startTime); 
        } 

        public Integer getBuffedValue(MapleBuffStat effect) { 
            MapleBuffStatValueHolder mbsvh = effects.get(effect); 
            if (mbsvh == null) { 
                return null; 
            } 
            return Integer.valueOf(mbsvh.value); 
        } 

        public int getBuffSource(MapleBuffStat stat) { 
            MapleBuffStatValueHolder mbsvh = effects.get(stat); 
            if (mbsvh == null) { 
                return -1; 
            } 
            return mbsvh.effect.getSourceId(); 
        } 

        private List<MapleBuffStat> getBuffStats(MapleStatEffect effect, long startTime) { 
            List<MapleBuffStat> stats = new ArrayList<>(); 
            for (Entry<MapleBuffStat, MapleBuffStatValueHolder> stateffect : effects.entrySet()) { 
                if (stateffect.getValue().effect.sameSource(effect) && (startTime == -1 || startTime == stateffect.getValue().startTime)) { 
                    stats.add(stateffect.getKey()); 
                } 
            } 
            return stats; 
        } 

        public int getChair() { 
            return chair; 
        } 

        public String getChalkboard() { 
            return this.chalktext; 
        } 

        public MapleClient getClient() { 
            return client; 
        } 

        public final List<MapleQuestStatus> getCompletedQuests() { 
            List<MapleQuestStatus> ret = new LinkedList<>(); 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus().equals(MapleQuestStatus.Status.COMPLETED)) { 
                    ret.add(q); 
                } 
            } 
            return Collections.unmodifiableList(ret); 
        } 

        public Collection<MapleMonster> getControlledMonsters() { 
            return Collections.unmodifiableCollection(controlled); 
        } 

        public List<MapleRing> getCrushRings() { 
            Collections.sort(crushRings); 
            return crushRings; 
        } 

        public int getCurrentCI() { 
            return ci; 
        } 

        public int getCurrentPage() { 
            return currentPage; 
        } 

        public int getCurrentMaxHp() { 
            return localmaxhp; 
        } 

        public int getCurrentMaxMp() { 
            return localmaxmp; 
        } 

        public int getCurrentTab() { 
            return currentTab; 
        } 

        public int getCurrentType() { 
            return currentType; 
        } 

        public int getDex() { 
            return dex; 
        } 

        public int getDojoEnergy() { 
            return dojoEnergy; 
        } 

        public boolean getDojoParty() { 
            return dojoParty; 
        } 

        public int getDojoPoints() { 
            return dojoPoints; 
        } 

        public int getDojoStage() { 
            return dojoStage; 
        } 

        public List<MapleDoor> getDoors() { 
            return new ArrayList<>(doors); 
        } 

        public int getDropRate() { 
            return dropRate; 
        } 

        public int getEnergyBar() { 
            return energybar; 
        } 

        public EventInstanceManager getEventInstance() { 
            return eventInstance; 
        } 

        public ArrayList<Integer> getExcluded() { 
            return excluded; 
        } 

        public int getExp() { 
            return exp.get(); 
        } 

        public int getGachaExp() { 
            return gachaexp.get(); 
        } 

        public int getExpRate() { 
            return expRate; 
        } 

        public int getFace() { 
            return face; 
        } 

        public int getFame() { 
            return fame; 
        } 

        public MapleFamily getFamily() { 
            return family; 
        } 

        public void setFamily(MapleFamily f) { 
            this.family = f; 
        } 

        public int getFamilyId() { 
            return familyId; 
        } 

        public boolean getFinishedDojoTutorial() { 
            return finishedDojoTutorial; 
        } 

        public List<MapleRing> getFriendshipRings() { 
            Collections.sort(friendshipRings); 
            return friendshipRings; 
        } 

        public int getGender() { 
            return gender; 
        } 

        public boolean isMale() { 
            return getGender() == 0; 
        } 

        public MapleGuild getGuild() { 
            try { 
                return Server.getInstance().getGuild(getGuildId(), null); 
            } catch (Exception ex) { 
                return null; 
            } 
        } 

        public int getGuildId() { 
            return guildid; 
        } 

        public int getGuildRank() { 
            return guildrank; 
        } 

        public int getHair() { 
            return hair; 
        } 

        public HiredMerchant getHiredMerchant() { 
            return hiredMerchant; 
        } 

        public int getHp() { 
            return hp; 
        } 

        public int getHpMpApUsed() { 
            return hpMpApUsed; 
        } 

        // NEVER CALL THIS UNLESS... 
        public void setId(int id) { 
            this.id = id; 
        } 

        public int getId() { 
            return id; 
        } 

        public static int getIdByName(String name) { 
            try { 
                int id; 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT id FROM characters WHERE name = ?")) { 
                    ps.setString(1, name); 
                    try (ResultSet rs = ps.executeQuery()) { 
                        if (!rs.next()) { 
                            rs.close(); 
                            ps.close(); 
                            return -1; 
                        } 
                        id = rs.getInt("id"); 
                    } 
                } 
                return id; 
            } catch (Exception e) { 
            } 
            return -1; 
        } 

        public static String getNameById(int id) { 
            try { 
                String name; 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT name FROM characters WHERE id = ?")) { 
                    ps.setInt(1, id); 
                    try (ResultSet rs = ps.executeQuery()) { 
                        if (!rs.next()) { 
                            rs.close(); 
                            ps.close(); 
                            return null; 
                        } 
                        name = rs.getString("name"); 
                    } 
                } 
                return name; 
            } catch (Exception e) { 
            } 
            return null; 
        } 

        public static int getAccountIdByCharacterName(String name) { 
            try { 
                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()) { 
                    return rs.getInt("accountid"); 
                } 
                rs.close(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
            return -1; 
        } 

        public int getInitialSpawnpoint() { 
            return initialSpawnPoint; 
        } 

        public int getInt() { 
            return int_; 
        } 

        public MapleInventory getInventory(MapleInventoryType type) { 
            return inventory[type.ordinal()]; 
        } 

        public int getItemEffect() { 
            return itemEffect; 
        } 

        public int getItemQuantity(int itemid, boolean checkEquipped) { 
            int possesed = inventory[MapleItemInformationProvider.getInstance().getInventoryType(itemid).ordinal()].countById(itemid); 
            if (checkEquipped) { 
                possesed += inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid); 
            } 
            return possesed; 
        } 

        public MapleJob getJob() { 
            return job; 
        } 

        public int getJobRank() { 
            return jobRank; 
        } 

        public int getJobRankMove() { 
            return jobRankMove; 
        } 

        public int getJobType() { 
            return job.getId() / 1000; 
        } 

        public Map<Integer, MapleKeyBinding> getKeymap() { 
            return keymap; 
        } 

        public long getLastHealed() { 
            return lastHealed; 
        } 

        public long getLastUsedCashItem() { 
            return lastUsedCashItem; 
        } 

        public int getLevel() { 
            return level; 
        } 

        public int getLuk() { 
            return luk; 
        } 

        public int getFh() { 
            if (getMap().getFootholds().findBelow(this.getPosition()) == null) { 
                return 0; 
            } else { 
                return getMap().getFootholds().findBelow(this.getPosition()).getId(); 
            } 
        } 

        public MapleMap getMap() { 
            return map; 
        } 

        public int getMapId() { 
            if (map != null) { 
                return map.getId(); 
            } 
            return mapid; 
        } 

        public int getMarkedMonster() { 
            return markedMonster; 
        } 

        public MapleRing getMarriageRing() { 
            return marriageRing; 
        } 

        public int getMarried() { 
            return married; 
        } 

        public int getMasterLevel(Skill skill) { 
            if (skills.get(skill) == null) { 
                return 0; 
            } 
            return skills.get(skill).masterlevel; 
        } 

        public int getMaxHp() { 
            return maxhp; 
        } 

        public int getMaxLevel() { 
            return 200; 
        } 

        public int getMaxMp() { 
            return maxmp; 
        } 

        public void setMeso(int i) { 
            meso.set(i); 
        } 

        public int getMeso() { 
            return meso.get(); 
        } 

        public int getMerchantMeso() { 
            return merchantmeso; 
        } 

        public int getMesoRate() { 
            return mesoRate; 
        } 

        public int getMesosTraded() { 
            return mesosTraded; 
        } 

        public int getMessengerPosition() { 
            return messengerposition; 
        } 

        public MapleGuildCharacter getMGC() { 
            return mgc; 
        } 

        public MaplePartyCharacter getMPC() { 
            // if (mpc == null) mpc = new MaplePartyCharacter(this); 
            return mpc; 
        } 

        public void setMPC(MaplePartyCharacter mpc) { 
            this.mpc = mpc; 
        } 

        public AbstractMinigame getMiniGame() { 
            return miniGame; 
        } 

        public int getMiniGamePoints(String type, boolean omok) { 
            if (omok) { 
                switch (type) { 
                    case "wins": 
                        return omokwins; 
                    case "losses": 
                        return omoklosses; 
                    default: 
                        return omokties; 
                } 
            } else { 
                switch (type) { 
                    case "wins": 
                        return matchcardwins; 
                    case "losses": 
                        return matchcardlosses; 
                    default: 
                        return matchcardties; 
                } 
            } 
        } 

        public MonsterBook getMonsterBook() { 
            return monsterbook; 
        } 

        public int getMonsterBookCover() { 
            return bookCover; 
        } 

        public MapleMount getMount() { 
            return maplemount; 
        } 

        public int getMp() { 
            return mp; 
        } 

        public MapleMessenger getMessenger() { 
            return messenger; 
        } 

        public String getName() { 
            return name; 
        } 

        public int getNextEmptyPetIndex() { 
            for (int i = 0; i < 3; i++) { 
                if (pets[i] == null) { 
                    return i; 
                } 
            } 
            return 3; 
        } 

        public int getNoPets() { 
            int ret = 0; 
            for (int i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    ret++; 
                } 
            } 
            return ret; 
        } 

        public int getNumControlledMonsters() { 
            return controlled.size(); 
        } 

        public MapleParty getParty() { 
            return party; 
        } 

        public int getPartyId() { 
            return (party != null ? party.getId() : -1); 
        } 

        public MaplePlayerShop getPlayerShop() { 
            return playerShop; 
        } 

        public MaplePet[] getPets() { 
            return pets; 
        } 

        public MaplePet getPet(int index) { 
            return pets[index]; 
        } 

        public byte getPetIndex(int petId) { 
            for (byte i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    if (pets[i].getUniqueId() == petId) { 
                        return i; 
                    } 
                } 
            } 
            return -1; 
        } 

        public byte getPetIndex(MaplePet pet) { 
            for (byte i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    if (pets[i].getUniqueId() == pet.getUniqueId()) { 
                        return i; 
                    } 
                } 
            } 
            return -1; 
        } 

        public int getPossibleReports() { 
            return possibleReports; 
        } 

        public final byte getQuestStatus(final int quest) { 
            for (final MapleQuestStatus q : quests.values()) { 
                if (q.getQuest().getId() == quest) { 
                    return (byte) q.getStatus().getId(); 
                } 
            } 
            return 0; 
        } 

        public MapleQuestStatus getQuest(MapleQuest quest) { 
            if (!quests.containsKey(quest)) { 
                return new MapleQuestStatus(quest, MapleQuestStatus.Status.NOT_STARTED); 
            } 
            return quests.get(quest); 
        } 

        public boolean needQuestItem(int questid, int itemid) { 
            if (questid <= 0) { 
                return true; // For non quest items :3 
            } 
            MapleQuest quest = MapleQuest.getInstance(questid); 
            return getInventory(ItemConstants.getInventoryType(itemid)).countById(itemid) < quest.getItemAmountNeeded(itemid); 
        } 

        public int getRank() { 
            return rank; 
        } 

        public int getRankMove() { 
            return rankMove; 
        } 

        public int getRemainingAp() { 
            return remainingAp; 
        } 

        public int getRemainingSp() { 
            return remainingSp; 
        } 

        public int getSavedLocation(String type) { 
            SavedLocation sl = savedLocations[SavedLocationType.fromString(type).ordinal()]; 
            if (sl == null) { 
                return 102000000; 
            } 
            int m = sl.getMapId(); 
            if (!SavedLocationType.fromString(type).equals(SavedLocationType.WORLDTOUR)) { 
                clearSavedLocation(SavedLocationType.fromString(type)); 
            } 
            return m; 
        } 

        public String getSearch() { 
            return search; 
        } 

        public MapleShop getShop() { 
            return shop; 
        } 

        public Map<Skill, SkillEntry> getSkills() { 
            return Collections.unmodifiableMap(skills); 
        } 

        public int getSkillLevel(int skill) { 
            SkillEntry ret = skills.get(SkillFactory.getSkill(skill)); 
            if (ret == null) { 
                return 0; 
            } 
            return ret.skillevel; 
        } 

        public byte getSkillLevel(Skill skill) { 
            if (skills.get(skill) == null) { 
                return 0; 
            } 
            return skills.get(skill).skillevel; 
        } 

        public long getSkillExpiration(int skill) { 
            SkillEntry ret = skills.get(SkillFactory.getSkill(skill)); 
            if (ret == null) { 
                return -1; 
            } 
            return ret.expiration; 
        } 

        public long getSkillExpiration(Skill skill) { 
            if (skills.get(skill) == null) { 
                return -1; 
            } 
            return skills.get(skill).expiration; 
        } 

        public MapleSkinColor getSkinColor() { 
            return skinColor; 
        } 

        public int getSlot() { 
            return slots; 
        } 

        public final List<MapleQuestStatus> getStartedQuests() { 
            List<MapleQuestStatus> ret = new LinkedList<>(); 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus().equals(MapleQuestStatus.Status.STARTED)) { 
                    ret.add(q); 
                } 
            } 
            return Collections.unmodifiableList(ret); 
        } 

        public final int getStartedQuestsSize() { 
            int i = 0; 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus().equals(MapleQuestStatus.Status.STARTED)) { 
                    if (q.getQuest().getInfoNumber() > 0) { 
                        i++; 
                    } 
                    i++; 
                } 
            } 
            return i; 
        } 

        public MapleStatEffect getStatForBuff(MapleBuffStat effect) { 
            MapleBuffStatValueHolder mbsvh = effects.get(effect); 
            if (mbsvh == null) { 
                return null; 
            } 
            return mbsvh.effect; 
        } 

        public MapleStorage getStorage() { 
            return storage; 
        } 

        public int getStr() { 
            return str; 
        } 

        public Map<Integer, MapleSummon> getSummons() { 
            return summons; 
        } 

        public int getTotalLuk() { 
            return localluk; 
        } 

        public int getTotalMagic() { 
            return magic; 
        } 

        public int getTotalWatk() { 
            return watk; 
        } 

        public MapleTrade getTrade() { 
            return trade; 
        } 

        public int getVanquisherKills() { 
            return vanquisherKills; 
        } 

        public int getVanquisherStage() { 
            return vanquisherStage; 
        } 

        public Collection<MapleMapObject> getVisibleMapObjects() { 
            return Collections.unmodifiableCollection(visibleMapObjects); 
        } 

        public int getWorld() { 
            return world; 
        } 

        public void giveCoolDowns(final int skillid, long starttime, long length) { 
            if (skillid == 5221999) { 
                this.battleshipHp = (int) length; 
                addCooldown(skillid, 0, length, null); 
            } else { 
                int time = (int) ((length + starttime) - System.currentTimeMillis()); 
                addCooldown(skillid, System.currentTimeMillis(), time, TimerManager.getInstance().schedule(new CancelCooldownAction(this, skillid), time)); 
            } 
        } 

        public int gmLevel() { 
            return gmLevel; 
        } 

        public String guildCost() { 
            return nf.format(MapleGuild.CREATE_GUILD_COST); 
        } 

        private void guildUpdate() { 
            if (this.guildid < 1) { 
                return; 
            } 
            mgc.setLevel(level); 
            mgc.setJobId(job.getId()); 
            try { 
                Server.getInstance().memberLevelJobUpdate(this.mgc); 
                int allianceId = getGuild().getAllianceId(); 
                if (allianceId > 0) { 
                    Server.getInstance().allianceMessage(allianceId, MaplePacketCreator.updateAllianceJobLevel(this), getId(), -1);
                } 
            } catch (Exception e) { 
                e.printStackTrace(); 
            } 
        } 

        public void handleEnergyChargeGain() { // to get here energychargelevel has to be > 0 
            Skill energycharge = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.ENERGY_CHARGE) : SkillFactory.getSkill(Marauder.ENERGY_CHARGE); 
            MapleStatEffect ceffect; 
            ceffect = energycharge.getEffect(getSkillLevel(energycharge)); 
            TimerManager tMan = TimerManager.getInstance(); 
            if (energybar < 10000) { 
                energybar += 102; 
                if (energybar > 10000) { 
                    energybar = 10000; 
                } 
                List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ENERGY_CHARGE, energybar)); 
                setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energybar); 
                client.announce(MaplePacketCreator.giveBuff(energybar, 0, stat)); 
                client.announce(MaplePacketCreator.showOwnBuffEffect(energycharge.getId(), 2)); 
                getMap().broadcastMessage(this, MaplePacketCreator.showBuffeffect(id, energycharge.getId(), 2)); 
                getMap().broadcastMessage(this, MaplePacketCreator.giveForeignBuff(energybar, stat)); 
            } 
            if (energybar >= 10000 && energybar < 11000) { 
                energybar = 15000; 
                final MapleCharacter chr = this; 
                tMan.schedule(new Runnable() { 
                   [MENTION=2000004426]Override[/MENTION] 
                    public void run() { 
                        energybar = 0; 
                        List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ENERGY_CHARGE, energybar)); 
                        setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energybar); 
                        client.announce(MaplePacketCreator.giveBuff(energybar, 0, stat)); 
                        getMap().broadcastMessage(chr, MaplePacketCreator.giveForeignBuff(energybar, stat)); 
                    } 
                }, ceffect.getDuration()); 
            } 
        } 

        public void handleOrbconsume() { 
            int skillid = isCygnus() ? DawnWarrior.COMBO : Crusader.COMBO; 
            Skill combo = SkillFactory.getSkill(skillid); 
            List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.COMBO, 1)); 
            setBuffedValue(MapleBuffStat.COMBO, 1); 
            client.announce(MaplePacketCreator.giveBuff(skillid, combo.getEffect(getSkillLevel(combo)).getDuration() + (int) ((getBuffedStarttime(MapleBuffStat.COMBO) - System.currentTimeMillis())), stat)); 
            getMap().broadcastMessage(this, MaplePacketCreator.giveForeignBuff(getId(), stat), false); 
        } 

        public boolean hasEntered(String script) { 
            for (int mapId : entered.keySet()) { 
                if (entered.get(mapId).equals(script)) { 
                    return true; 
                } 
            } 
            return false; 
        } 

        public boolean hasEntered(String script, int mapId) { 
            if (entered.containsKey(mapId)) { 
                if (entered.get(mapId).equals(script)) { 
                    return true; 
                } 
            } 
            return false; 
        } 

        public void hasGivenFame(MapleCharacter to) { 
            lastfametime = System.currentTimeMillis(); 
            lastmonthfameids.add(Integer.valueOf(to.getId())); 
            try { 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO famelog (characterid, characterid_to) VALUES (?, ?)")) { 
                    ps.setInt(1, getId()); 
                    ps.setInt(2, to.getId()); 
                    ps.executeUpdate(); 
                } 
            } catch (SQLException e) { 
            } 
        } 

        public boolean hasMerchant() { 
            return hasMerchant; 
        } 

        public boolean haveItem(int itemid) { 
            return getItemQuantity(itemid, false) > 0; 
        } 

        public void increaseGuildCapacity() { // hopefully nothing is null 
            if (getMeso() < getGuild().getIncreaseGuildCost(getGuild().getCapacity())) { 
                dropMessage(1, "You don't have enough mesos."); 
                return; 
            } 
            Server.getInstance().increaseGuildCapacity(guildid); 
            gainMeso(-getGuild().getIncreaseGuildCost(getGuild().getCapacity()), true, false, false); 
        } 

        public boolean isActiveBuffedValue(int skillid) { 
            LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList<>(effects.values()); 
            for (MapleBuffStatValueHolder mbsvh : allBuffs) { 
                if (mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) { 
                    return true; 
                } 
            } 
            return false; 
        } 

        public boolean isAlive() { 
            return hp > 0; 
        } 

        public boolean isBuffFrom(MapleBuffStat stat, Skill skill) { 
            MapleBuffStatValueHolder mbsvh = effects.get(stat); 
            if (mbsvh == null) { 
                return false; 
            } 
            return mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skill.getId(); 
        } 

        public boolean isCygnus() { 
            return getJobType() == 1; 
        } 

        public boolean isAran() { 
            return getJob().getId() >= 2000 && getJob().getId() <= 2112; 
        } 

        public boolean isBeginnerJob() { 
            return (getJob().getId() == 0 || getJob().getId() == 1000 || getJob().getId() == 2000) && getLevel() < 11; 
        } 

        public boolean isGM() { 
            return gmLevel >= 3; 
        } 

        public boolean isHidden() { 
            return hidden; 
        } 

        public boolean isMapObjectVisible(MapleMapObject mo) { 
            return visibleMapObjects.contains(mo); 
        } 

        public boolean isPartyLeader() { 
            return party.getLeader() == party.getMemberById(getId()); 
        } 

        public void leaveMap() { 
            controlled.clear(); 
            visibleMapObjects.clear(); 
            if (chair != 0) { 
                chair = 0; 
            } 
            if (hpDecreaseTask != null) { 
                hpDecreaseTask.cancel(false); 
            } 
        } 
             
            public final void RandomLevelUpBonus(String... aArgs){ 
          MapleCharacter player = getClient().getPlayer(); 
          int cashAmount=(int)(10*Math.random()); 
          getClient().getChannelServer().getPlayerStorage().getCharacterByName(getName()).getCashShop().gainCash(1, cashAmount*100); 
          if (ServerConstants.levelup_bonuses == true) { 
          int randomInt=(int)(100*Math.random()); 
          if (randomInt == 1 && cashAmount*100 > 0) { 
          remainingAp += 5; 
          player.dropMessage("You have gained 5 extra AP and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 1 && cashAmount*100 == 0) { 
          remainingAp += 5; 
          player.dropMessage("You have gained 5 extra AP!"); 
          } 

          if (randomInt == 2 && cashAmount*100 > 0) { 
          player.gainMeso(100000, true); 
          player.dropMessage("You have gained 100,000 Mesos and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 2 && cashAmount*100 == 0) { 
          player.gainMeso(100000, true); 
          player.dropMessage("You have gained 100,000 Mesos!"); 
          } 
          if (randomInt == 3 && cashAmount*100 > 0) { 
          player.gainMeso(40000, true); 
          player.dropMessage("You have gained 40,000 Mesos and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 3 && cashAmount*100 == 0) { 
          player.gainMeso(40000, true); 
          player.dropMessage("You have gained 40,000 Mesos!"); 
          } 
          if (randomInt == 4 && cashAmount*100 > 0 || randomInt == 5 && cashAmount*100 > 0) { 
          player.gainMeso(20000, true); 
          player.dropMessage("You have gained 20,000 Mesos and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 4 && cashAmount*100 == 0 || randomInt == 5 && cashAmount*100 == 0) { 
          player.gainMeso(20000, true); 
          player.dropMessage("You have gained 20,000 Mesos!"); 
          } 
          if (randomInt == 6 && cashAmount*100 > 0) { 
          player.levelUp(false); 
          player.dropMessage("Double level up and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 6 && cashAmount*100 == 0) { 
          player.levelUp(false); 
          player.dropMessage("Double level up!"); 
          } 
          if (randomInt == 7 && cashAmount*100 > 0) { 
          int fameAmount=(int)(31*Math.random()+1); 
          player.gainFame(fameAmount); 
          player.dropMessage("You have gained " + fameAmount + " fame and " +cashAmount*100 + " NX cash!"); 
          if (randomInt == 7 && cashAmount*100 == 0) { 
          int fameAmountTwo=(int)(31*Math.random()+1); 
          player.gainFame(fameAmountTwo); 
          player.dropMessage("You have gained " + fameAmount + " fame!"); 
          } 
          if (randomInt > 7 && randomInt < 15) { 
          player.addExpBonus(); 
          player.dropMessage("You have gained an expbonus!"); 
          } 

          } else { 
              if (cashAmount*100 > 0) { 
             // player.dropMessage("You have gained " +cashAmount*100 + " NX cash!"); 
              } 
          } 
     } 
        } 

        public void levelUp(boolean takeexp) { 
            Skill improvingMaxHP = null; 
            Skill improvingMaxMP = null; 
            int improvingMaxHPLevel = 0; 
            int improvingMaxMPLevel = 0; 

            remainingAp += 5; 
            if (isCygnus() && level < 70) { 
                remainingAp++; 
            } 
            if (job == MapleJob.BEGINNER || job == MapleJob.NOBLESSE || job == MapleJob.LEGEND) { 
                maxhp += Randomizer.next(12, 16); 
                maxmp += Randomizer.next(10, 12); 
            } else if (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.DAWNWARRIOR1)) { 
                improvingMaxHP = isCygnus() ? SkillFactory.getSkill(DawnWarrior.MAX_HP_INCREASE) : SkillFactory.getSkill(Swordsman.IMPROVED_MAX_HP_INCREASE); 
                if (job.isA(MapleJob.CRUSADER)) { 
                    improvingMaxMP = SkillFactory.getSkill(1210000); 
                } else if (job.isA(MapleJob.DAWNWARRIOR2)) { 
                    improvingMaxMP = SkillFactory.getSkill(11110000); 
                } 
                improvingMaxHPLevel = getSkillLevel(improvingMaxHP); 
                maxhp += Randomizer.next(24, 28); 
                maxmp += Randomizer.next(4, 6); 
            } else if (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.BLAZEWIZARD1)) { 
                improvingMaxMP = isCygnus() ? SkillFactory.getSkill(BlazeWizard.INCREASING_MAX_MP) : SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE); 
                improvingMaxMPLevel = getSkillLevel(improvingMaxMP); 
                maxhp += Randomizer.next(10, 14); 
                maxmp += Randomizer.next(22, 24); 
            } else if (job.isA(MapleJob.BOWMAN) || job.isA(MapleJob.THIEF) || (job.getId() > 1299 && job.getId() < 1500)) { 
                maxhp += Randomizer.next(20, 24); 
                maxmp += Randomizer.next(14, 16); 
            } else if (job.isA(MapleJob.GM)) { 
                maxhp = 30000; 
                maxmp = 30000; 
            } else if (job.isA(MapleJob.PIRATE) || job.isA(MapleJob.THUNDERBREAKER1)) { 
                improvingMaxHP = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.IMPROVE_MAX_HP) : SkillFactory.getSkill(5100000); 
                improvingMaxHPLevel = getSkillLevel(improvingMaxHP); 
                maxhp += Randomizer.next(22, 28); 
                maxmp += Randomizer.next(18, 23); 
            } else if (job.isA(MapleJob.ARAN1)) { 
                maxhp += Randomizer.next(44, 48); 
                int aids = Randomizer.next(4, 8); 
                maxmp += aids + Math.floor(aids * 0.1); 
            } 
            if (improvingMaxHPLevel > 0 && (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.PIRATE) || job.isA(MapleJob.DAWNWARRIOR1))) { 
                maxhp += improvingMaxHP.getEffect(improvingMaxHPLevel).getX(); 
            } 
            if (improvingMaxMPLevel > 0 && (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.CRUSADER) || job.isA(MapleJob.BLAZEWIZARD1))) { 
                maxmp += improvingMaxMP.getEffect(improvingMaxMPLevel).getX(); 
            } 
            maxmp += localint_ / 10; 
            if (takeexp) { 
                exp.addAndGet(-ExpTable.getExpNeededForLevel(level)); 
                if (exp.get() < 0) { 
                    exp.set(0); 
                } 
            } 
            level++; 
            if (level >= getMaxLevel()) { 
                exp.set(0); 
            } 
            maxhp = Math.min(30000, maxhp); 
            maxmp = Math.min(30000, maxmp); 
            if (level == 200) { 
                exp.set(0); 
            } 
            hp = maxhp; 
            mp = maxmp; 
            recalcLocalStats(); 
            List<Pair<MapleStat, Integer>> statup = new ArrayList<>(10); 
            statup.add(new Pair<>(MapleStat.AVAILABLEAP, remainingAp)); 
            statup.add(new Pair<>(MapleStat.HP, localmaxhp)); 
            statup.add(new Pair<>(MapleStat.MP, localmaxmp)); 
            statup.add(new Pair<>(MapleStat.EXP, exp.get())); 
            statup.add(new Pair<>(MapleStat.LEVEL, level)); 
            statup.add(new Pair<>(MapleStat.MAXHP, maxhp)); 
            statup.add(new Pair<>(MapleStat.MAXMP, maxmp)); 
            statup.add(new Pair<>(MapleStat.STR, str)); 
            statup.add(new Pair<>(MapleStat.DEX, dex)); 
            if (job.getId() % 1000 > 0) { 
                remainingSp += 3; 
                statup.add(new Pair<>(MapleStat.AVAILABLESP, remainingSp)); 
            } 
            client.announce(MaplePacketCreator.updatePlayerStats(statup)); 
            getMap().broadcastMessage(this, MaplePacketCreator.showForeignEffect(getId(), 0), false); 
            recalcLocalStats(); 
            setMPC(new MaplePartyCharacter(this)); 
            silentPartyUpdate(); 
                    RandomLevelUpBonus(); 
            /* 
             * if (this.guildid > 0) { 
             * getGuild().broadcast(MaplePacketCreator.levelUpMessage(2, level, name), this.getId()); 
             * } 
             */ 
            if (ServerConstants.PERFECT_PITCH) { 
                // milestones? 
                if (MapleInventoryManipulator.checkSpace(client, 4310000, (short) 1, "")) { 
                    MapleInventoryManipulator.addById(client, 4310000, (short) 1); 
                } 
            } 
            guildUpdate(); 
        } 

        public static MapleCharacter loadCharFromDB(int charid, MapleClient client, boolean channelserver) throws SQLException { 
            try { 
                MapleCharacter ret = new MapleCharacter(); 
                ret.client = client; 
                ret.id = charid; 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE id = ?"); 
                ps.setInt(1, charid); 
                ResultSet rs = ps.executeQuery(); 
                if (!rs.next()) { 
                    rs.close(); 
                    ps.close(); 
                    throw new RuntimeException("Loading char failed (not found)"); 
                } 
                ret.name = rs.getString("name"); 
                ret.level = rs.getInt("level"); 
                ret.fame = rs.getInt("fame"); 
                ret.str = rs.getInt("str"); 
                ret.dex = rs.getInt("dex"); 
                ret.int_ = rs.getInt("int"); 
                ret.luk = rs.getInt("luk"); 
                ret.exp.set(rs.getInt("exp")); 
                ret.gachaexp.set(rs.getInt("gachaexp")); 
                ret.hp = rs.getInt("hp"); 
                ret.maxhp = rs.getInt("maxhp"); 
                ret.mp = rs.getInt("mp"); 
                ret.maxmp = rs.getInt("maxmp"); 
                ret.hpMpApUsed = rs.getInt("hpMpUsed"); 
                ret.hasMerchant = rs.getInt("HasMerchant") == 1; 
                ret.remainingSp = rs.getInt("sp"); 
                ret.remainingAp = rs.getInt("ap"); 
                ret.meso.set(rs.getInt("meso")); 
                ret.merchantmeso = rs.getInt("MerchantMesos"); 
                ret.gmLevel = rs.getInt("gm"); 
                ret.skinColor = MapleSkinColor.getById(rs.getInt("skincolor")); 
                ret.gender = rs.getInt("gender"); 
                ret.job = MapleJob.getById(rs.getInt("job")); 
                ret.finishedDojoTutorial = rs.getInt("finishedDojoTutorial") == 1; 
                ret.vanquisherKills = rs.getInt("vanquisherKills"); 
                ret.omokwins = rs.getInt("omokwins"); 
                ret.omoklosses = rs.getInt("omoklosses"); 
                ret.omokties = rs.getInt("omokties"); 
                ret.matchcardwins = rs.getInt("matchcardwins"); 
                ret.matchcardlosses = rs.getInt("matchcardlosses"); 
                ret.matchcardties = rs.getInt("matchcardties"); 
                ret.hair = rs.getInt("hair"); 
                ret.face = rs.getInt("face"); 
                ret.accountid = rs.getInt("accountid"); 
                ret.mapid = rs.getInt("map"); 
                ret.initialSpawnPoint = rs.getInt("spawnpoint"); 
                ret.world = rs.getByte("world"); 
                ret.rank = rs.getInt("rank"); 
                ret.rankMove = rs.getInt("rankMove"); 
                ret.jobRank = rs.getInt("jobRank"); 
                ret.jobRankMove = rs.getInt("jobRankMove"); 
                int mountexp = rs.getInt("mountexp"); 
                int mountlevel = rs.getInt("mountlevel"); 
                int mounttiredness = rs.getInt("mounttiredness"); 
                ret.guildid = rs.getInt("guildid"); 
                ret.guildrank = rs.getInt("guildrank"); 
                            ret.legend = rs.getInt("legend"); 
                ret.allianceRank = rs.getInt("allianceRank"); 
                ret.familyId = rs.getInt("familyId"); 
                ret.bookCover = rs.getInt("monsterbookcover"); 
                ret.monsterbook = new MonsterBook(); 
                ret.monsterbook.loadCards(charid); 
                ret.vanquisherStage = rs.getInt("vanquisherStage"); 
                ret.dojoPoints = rs.getInt("dojoPoints"); 
                ret.dojoStage = rs.getInt("lastDojoStage"); 
                ret.reborns = rs.getInt("reborns"); 
                ret.jumppoints = rs.getInt("jumppoints"); 
                ret.jailed = rs.getBoolean("jailed"); 
                ret.jailtime = rs.getLong("jailtime"); 
                ret.jailduration = rs.getLong("jailduration"); 
                ret.eventpoints = rs.getInt("eventpoints"); 
                            ret.legend = rs.getInt("legend"); 
                            ret.horntail_slyed = rs.getInt("horntail_slyed"); 
                            ret.pinkbeen_slyed = rs.getInt("pinkbeen_slyed"); 
                if (rs.getInt("occuid") != -1) 
                    ret.occupation = OccupationEntry.generateEntry(ret, rs.getInt("occuid"), rs.getInt("occulevel"), rs.getInt("occuexp")); 
                if (ret.guildid > 0) { 
                    ret.mgc = new MapleGuildCharacter(ret); 
                } 
                int buddyCapacity = rs.getInt("buddyCapacity"); 
                ret.buddylist = new BuddyList(buddyCapacity); 
                ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(rs.getByte("equipslots")); 
                ret.getInventory(MapleInventoryType.USE).setSlotLimit(rs.getByte("useslots")); 
                ret.getInventory(MapleInventoryType.SETUP).setSlotLimit(rs.getByte("setupslots")); 
                ret.getInventory(MapleInventoryType.ETC).setSlotLimit(rs.getByte("etcslots")); 
                for (Pair<Item, MapleInventoryType> item : ItemFactory.INVENTORY.loadItems(ret.id, !channelserver)) { 
                    ret.getInventory(item.getRight()).addFromDB(item.getLeft()); 
                    Item itemz = item.getLeft(); 
                    if (itemz.getPetId() > -1) { 
                        MaplePet pet = itemz.getPet(); 
                        if (pet != null && pet.isSummoned()) { 
                            ret.addPet(pet); 
                        } 
                        continue; 
                    } 
                    if (item.getRight().equals(MapleInventoryType.EQUIP) || item.getRight().equals(MapleInventoryType.EQUIPPED)) { 
                        Equip equip = (Equip) item.getLeft(); 
                        if (equip.getRingId() > -1) { 
                            MapleRing ring = MapleRing.loadFromDb(equip.getRingId()); 
                            if (item.getRight().equals(MapleInventoryType.EQUIPPED)) { 
                                ring.equip(); 
                            } 
                            if (ring.getItemId() > 1112012) { 
                                ret.addFriendshipRing(ring); 
                            } else { 
                                ret.addCrushRing(ring); 
                            } 
                        } 
                    } 
                } 
                if (channelserver) { 
                    MapleMapFactory mapFactory = client.getChannelServer().getMapFactory(); 
                    ret.map = mapFactory.getMap(ret.mapid); 
                    if (ret.map == null) { 
                        ret.map = mapFactory.getMap(100000000); 
                    } 
                    MaplePortal portal = ret.map.getPortal(ret.initialSpawnPoint); 
                    if (portal == null) { 
                        portal = ret.map.getPortal(0); 
                        ret.initialSpawnPoint = 0; 
                    } 
                    ret.setPosition(portal.getPosition()); 
                    int partyid = rs.getInt("party"); 
                    MapleParty party = Server.getInstance().getWorld(ret.world).getParty(partyid); 
                    if (party != null) { 
                        ret.mpc = party.getMemberById(ret.id); 
                        if (ret.mpc != null) { 
                            ret.party = party; 
                        } 
                    } 
                    int messengerid = rs.getInt("messengerid"); 
                    int position = rs.getInt("messengerposition"); 
                    if (messengerid > 0 && position < 4 && position > -1) { 
                        MapleMessenger messenger = Server.getInstance().getWorld(ret.world).getMessenger(messengerid); 
                        if (messenger != null) { 
                            ret.messenger = messenger; 
                            ret.messengerposition = position; 
                        } 
                    } 
                    ret.loggedIn = true; 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT mapid,vip FROM trocklocations WHERE characterid = ? LIMIT 15"); 
                ps.setInt(1, charid); 
                rs = ps.executeQuery(); 
                byte v = 0; 
                byte r = 0; 
                while (rs.next()) { 
                    if (rs.getInt("vip") == 1) { 
                        ret.viptrockmaps[v] = rs.getInt("mapid"); 
                        v++; 
                    } else { 
                        ret.trockmaps[r] = rs.getInt("mapid"); 
                        r++; 
                    } 
                } 
                while (v < 10) { 
                    ret.viptrockmaps[v] = 999999999; 
                    v++; 
                } 
                while (r < 5) { 
                    ret.trockmaps[r] = 999999999; 
                    r++; 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT name FROM accounts WHERE id = ?", Statement.RETURN_GENERATED_KEYS); 
                ps.setInt(1, ret.accountid); 
                rs = ps.executeQuery(); 
                if (rs.next()) { 
                    ret.getClient().setAccountName(rs.getString("name")); 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT `area`,`info` FROM area_info WHERE charid = ?"); 
                ps.setInt(1, ret.id); 
                rs = ps.executeQuery(); 
                while (rs.next()) { 
                    ret.area_info.put(rs.getShort("area"), rs.getString("info")); 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT `name`,`info` FROM eventstats WHERE characterid = ?"); 
                ps.setInt(1, ret.id); 
                rs = ps.executeQuery(); 
                while (rs.next()) { 
                    String name = rs.getString("name"); 
                    if (rs.getString("name").equals("rescueGaga")) { 
                        ret.events.put(name, new RescueGaga(rs.getInt("info"))); 
                    } 
                    // ret.events = new MapleEvents(new RescueGaga(rs.getInt("rescuegaga")), new ArtifactHunt(rs.getInt("artifacthunt"))); 
                } 
                rs.close(); 
                ps.close(); 
                ret.cashshop = new CashShop(ret.accountid, ret.id, ret.getJobType()); 
                ret.autoban = new AutobanManager(ret); 
                ret.marriageRing = null; // for now 
                ps = con.prepareStatement("SELECT name, level FROM characters WHERE accountid = ? AND id != ? ORDER BY level DESC limit 1"); 
                ps.setInt(1, ret.accountid); 
                ps.setInt(2, charid); 
                rs = ps.executeQuery(); 
                if (rs.next()) { 
                    ret.linkedName = rs.getString("name"); 
                    ret.linkedLevel = rs.getInt("level"); 
                } 
                rs.close(); 
                ps.close(); 
                if (channelserver) { 
                    ps = con.prepareStatement("SELECT * FROM queststatus WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    PreparedStatement psf; 
                    try (PreparedStatement pse = con.prepareStatement("SELECT * FROM questprogress WHERE queststatusid = ?")) { 
                        psf = con.prepareStatement("SELECT mapid FROM medalmaps WHERE queststatusid = ?"); 
                        while (rs.next()) { 
                            MapleQuest q = MapleQuest.getInstance(rs.getShort("quest")); 
                            MapleQuestStatus status = new MapleQuestStatus(q, MapleQuestStatus.Status.getById(rs.getInt("status"))); 
                            long cTime = rs.getLong("time"); 
                            if (cTime > -1) { 
                                status.setCompletionTime(cTime * 1000); 
                            } 
                            status.setForfeited(rs.getInt("forfeited")); 
                            ret.quests.put(q, status); 
                            pse.setInt(1, rs.getInt("queststatusid")); 
                            try (ResultSet rsProgress = pse.executeQuery()) { 
                                while (rsProgress.next()) { 
                                    status.setProgress(rsProgress.getInt("progressid"), rsProgress.getString("progress")); 
                                } 
                            } 
                            psf.setInt(1, rs.getInt("queststatusid")); 
                            try (ResultSet medalmaps = psf.executeQuery()) { 
                                while (medalmaps.next()) { 
                                    status.addMedalMap(medalmaps.getInt("mapid")); 
                                } 
                            } 
                        } 
                        rs.close(); 
                        ps.close(); 
                    } 
                    psf.close(); 

                    ps = con.prepareStatement("SELECT * FROM customQuestStatus WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    PreparedStatement pse = con.prepareStatement("SELECT * FROM customQuestMobs WHERE queststatusid = ?"); 
                    while (rs.next()) { 
                        final int id = rs.getInt("quest"); 
                        final CustomQuest q = CustomQuestProvider.getInstance(id); 
                        final MapleCustomQuestStatus status = new MapleCustomQuestStatus(q, rs.getByte("status")); 
                        final long cTime = rs.getLong("time"); 
                        if (cTime > -1) { 
                            status.setCompletionTime(cTime * 1000); 
                        } 
                        status.setCustomData(rs.getString("customData")); 
                        ret.customQuests.put(q, status); 
                        pse.setInt(1, rs.getInt("id")); 
                        final ResultSet rsMobs = pse.executeQuery(); 

                        while (rsMobs.next()) { 
                            status.setMobKills(rsMobs.getInt("mob"), rsMobs.getInt("count")); 
                        } 
                        rsMobs.close(); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    pse.close(); 

                    ps = con.prepareStatement("SELECT skillid,skilllevel,masterlevel,expiration FROM skills WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        ret.skills.put(SkillFactory.getSkill(rs.getInt("skillid")), new SkillEntry(rs.getByte("skilllevel"), rs.getInt("masterlevel"), rs.getLong("expiration"))); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT SkillID,StartTime,length FROM cooldowns WHERE charid = ?"); 
                    ps.setInt(1, ret.getId()); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        final int skillid = rs.getInt("SkillID"); 
                        final long length = rs.getLong("length"), startTime = rs.getLong("StartTime"); 
                        if (skillid != 5221999 && (length + startTime < System.currentTimeMillis())) { 
                            continue; 
                        } 
                        ret.giveCoolDowns(skillid, startTime, length); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("DELETE FROM cooldowns WHERE charid = ?"); 
                    ps.setInt(1, ret.getId()); 
                    ps.executeUpdate(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT * FROM skillmacros WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        int position = rs.getInt("position"); 
                        SkillMacro macro = new SkillMacro(rs.getInt("skill1"), rs.getInt("skill2"), rs.getInt("skill3"), rs.getString("name"), rs.getInt("shout"), position); 
                        ret.skillMacros[position] = macro; 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT `key`,`type`,`action` FROM keymap WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        int key = rs.getInt("key"); 
                        int type = rs.getInt("type"); 
                        int action = rs.getInt("action"); 
                        ret.keymap.put(Integer.valueOf(key), new MapleKeyBinding(type, action)); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT `locationtype`,`map`,`portal` FROM savedlocations WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        ret.savedLocations[SavedLocationType.valueOf(rs.getString("locationtype")).ordinal()] = new SavedLocation(rs.getInt("map"), rs.getInt("portal")); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT `characterid_to`,`when` FROM famelog WHERE characterid = ? AND DATEDIFF(NOW(),`when`) < 30"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    ret.lastfametime = 0; 
                    ret.lastmonthfameids = new ArrayList<>(31); 
                    while (rs.next()) { 
                        ret.lastfametime = Math.max(ret.lastfametime, rs.getTimestamp("when").getTime()); 
                        ret.lastmonthfameids.add(Integer.valueOf(rs.getInt("characterid_to"))); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ret.buddylist.loadFromDb(charid); 
                    ret.storage = MapleStorage.loadOrCreateFromDB(ret.accountid, ret.world); 
                    ret.recalcLocalStats(); 
                    // ret.resetBattleshipHp(); 
                    ret.silentEnforceMaxHpMp(); 
                } 
                int mountid = ret.getJobType() * 10000000 + 1004; 
                if (ret.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18) != null) { 
                    ret.maplemount = new MapleMount(ret, ret.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18).getItemId(), mountid); 
                } else { 
                    ret.maplemount = new MapleMount(ret, 0, mountid); 
                } 
                ret.maplemount.setExp(mountexp); 
                ret.maplemount.setLevel(mountlevel); 
                ret.maplemount.setTiredness(mounttiredness); 
                ret.maplemount.setActive(false); 
                return ret; 
            } catch (SQLException | RuntimeException e) { 
                e.printStackTrace(); 
            } 
            return null; 
        } 

        public static String makeMapleReadable(String in) { 
            String i = in.replace('I', 'i'); 
            i = i.replace('l', 'L'); 
            i = i.replace("rn", "Rn"); 
            i = i.replace("vv", "Vv"); 
            i = i.replace("VV", "Vv"); 
            return i; 

        } 

        private static class MapleBuffStatValueHolder { 

            public MapleStatEffect effect; 
            public long startTime; 
            public int value; 
            public ScheduledFuture<?schedule

            public 
    MapleBuffStatValueHolder(MapleStatEffect effectlong startTimeScheduledFuture<?> 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, length; 
            public ScheduledFuture<?timer

            public 
    MapleCoolDownValueHolder(int skillIdlong startTimelong lengthScheduledFuture<?> timer) { 
                super(); 
                this.skillId = skillId; 
                this.startTime = startTime; 
                this.length = length; 
                this.timer = timer; 
            } 
        } 

        public void message(String m) { 
            dropMessage(5, m); 
        } 

        public void yellowMessage(String m) { 
            announce(MaplePacketCreator.sendYellowTip(m)); 
        } 

        public void mobKilled(int id) { 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus() == MapleQuestStatus.Status.COMPLETED || q.getQuest().canComplete(this, null)) { 
                    continue; 
                } 
                String progress = q.getProgress(id); 
                if (!progress.isEmpty() && Integer.parseInt(progress) >= q.getQuest().getMobAmountNeeded(id)) { 
                    continue; 
                } 
                if (q.progress(id)) { 
                    client.announce(MaplePacketCreator.updateQuest(q.getQuest().getId(), q.getQuestData())); 
                } 
            } 
        } 

        public void mount(int id, int skillid) { 
            maplemount = new MapleMount(this, id, skillid); 
        } 

        public void playerNPC(MapleCharacter v, int scriptId) { 
            int npcId; 
            try { 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("SELECT id FROM playernpcs WHERE ScriptId = ?"); 
                ps.setInt(1, scriptId); 
                ResultSet rs = ps.executeQuery(); 
                if (!rs.next()) { 
                    rs.close(); 
                    ps = con.prepareStatement("INSERT INTO playernpcs (name, hair, face, skin, x, cy, map, gender, ScriptId, Foothold, rx0, rx1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS); 
                    ps.setString(1, v.getName()); 
                    ps.setInt(2, v.getHair()); 
                    ps.setInt(3, v.getFace()); 
                    ps.setInt(4, v.getSkinColor().getId()); 
                    ps.setInt(5, getPosition().x); 
                    ps.setInt(6, getPosition().y); 
                    ps.setInt(7, getMapId()); 
                    ps.setInt(8, getGender()); 
                    ps.setInt(9, scriptId); 
                    ps.setInt(10, getMap().getFootholds().findBelow(getPosition()).getId()); 
                    ps.setInt(11, getPosition().x); 
                    ps.setInt(12, getPosition().x); 
                    ps.executeUpdate(); 
                    rs = ps.getGeneratedKeys(); 
                    rs.next(); 
                    npcId = rs.getInt(1); 
                    ps.close(); 
                    ps = con.prepareStatement("INSERT INTO playernpcs_equip (NpcId, equipid, equippos) VALUES (?, ?, ?)"); 
                    ps.setInt(1, npcId); 
                    for (Item equip : getInventory(MapleInventoryType.EQUIPPED)) { 
                        int position = Math.abs(equip.getPosition()); 
                        if ((position < 12 && position > 0) || (position > 100 && position < 112)) { 
                            ps.setInt(2, equip.getItemId()); 
                            ps.setInt(3, equip.getPosition()); 
                            ps.addBatch(); 
                        } 
                    } 
                    ps.executeBatch(); 
                    ps.close(); 
                    rs.close(); 
                    ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?"); 
                    ps.setInt(1, scriptId); 
                    rs = ps.executeQuery(); 
                    rs.next(); 
                    PlayerNPCs pn = new PlayerNPCs(rs); 
                    for (Channel channel : Server.getInstance().getChannelsFromWorld(world)) { 
                        MapleMap m = channel.getMapFactory().getMap(getMapId()); 
                        m.broadcastMessage(MaplePacketCreator.spawnPlayerNPC(pn)); 
                        m.broadcastMessage(MaplePacketCreator.getPlayerNPC(pn)); 
                        m.addMapObject(pn); 
                    } 
                } 
                ps.close(); 
                rs.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        private void playerDead() { 
            cancelAllBuffs(false); 
            dispelDebuffs(); 
            if (getEventInstance() != null) { 
                getEventInstance().playerKilled(this); 
            } 
            int[] charmID = { 5130000, 4031283, 4140903 }; 
            int possesed = 0; 
            int i; 
            for (i = 0; i < charmID.length; i++) { 
                int quantity = getItemQuantity(charmID[i], false); 
                if (possesed == 0 && quantity > 0) { 
                    possesed = quantity; 
                    break; 
                } 
            } 
            if (possesed > 0) { 
                message("You have used a safety charm, so your EXP points have not been decreased."); 
                MapleInventoryManipulator.removeById(client, MapleItemInformationProvider.getInstance().getInventoryType(charmID[i]), charmID[i], 1, true, false); 
            } else if (mapid > 925020000 && mapid < 925030000) { 
                this.dojoStage = 0; 
            } else if (mapid > 980000100 && mapid < 980000700) { 
                getMap().broadcastMessage(this, MaplePacketCreator.CPQDied(this)); 
            } else if (getJob() != MapleJob.BEGINNER) { // Hmm... 
                int XPdummy = ExpTable.getExpNeededForLevel(getLevel()); 
                if (getMap().isTown()) { 
                    XPdummy /= 100; 
                } 
                if (XPdummy == ExpTable.getExpNeededForLevel(getLevel())) { 
                    if (getLuk() <= 100 && getLuk() > 8) { 
                        XPdummy *= (200 - getLuk()) / 2000; 
                    } else if (getLuk() < 8) { 
                        XPdummy /= 10; 
                    } else { 
                        XPdummy /= 20; 
                    } 
                } 
                if (getExp() > XPdummy) { 
                    gainExp(-XPdummy, false, false); 
                } else { 
                    gainExp(-getExp(), false, false); 
                } 
            } 
            if (getBuffedValue(MapleBuffStat.MORPH) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.MORPH); 
            } 

            if (getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING); 
            } 

            if (getChair() == -1) { 
                setChair(0); 
                client.announce(MaplePacketCreator.cancelChair(-1)); 
                getMap().broadcastMessage(this, MaplePacketCreator.showChair(getId(), 0), false); 
            } 
            client.announce(MaplePacketCreator.enableActions()); 
        } 

        private void prepareDragonBlood(final MapleStatEffect bloodEffect) { 
            if (dragonBloodSchedule != null) { 
                dragonBloodSchedule.cancel(false); 
            } 
            dragonBloodSchedule = TimerManager.getInstance().register(new Runnable() { 
               [MENTION=2000004426]Override[/MENTION] 
                public void run() { 
                    addHP(-bloodEffect.getX()); 
                    client.announce(MaplePacketCreator.showOwnBuffEffect(bloodEffect.getSourceId(), 5)); 
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(getId(), bloodEffect.getSourceId(), 5), false); 
                    checkBerserk(); 
                } 
            }, 4000, 4000); 
        } 

        private void recalcLocalStats() { 
            int oldmaxhp = localmaxhp; 
            localmaxhp = getMaxHp(); 
            localmaxmp = getMaxMp(); 
            localdex = getDex(); 
            localint_ = getInt(); 
            localstr = getStr(); 
            localluk = getLuk(); 
            int speed = 100, jump = 100; 
            magic = localint_; 
            watk = 0; 
            for (Item item : getInventory(MapleInventoryType.EQUIPPED)) { 
                Equip equip = (Equip) 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(); 
            } 
            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)) { 
                Skill expert = null; 
                if (job.isA(MapleJob.MARKSMAN)) { 
                    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; 
            // } 
            if (oldmaxhp != 0 && oldmaxhp != localmaxhp) { 
                updatePartyMemberHP(); 
            } 
        } 

        public void receivePartyMemberHP() { 
            if (party != null) { 
                int channel = client.getChannel(); 
                for (MaplePartyCharacter partychar : party.getMembers()) { 
                    if (partychar.getMapId() == getMapId() && partychar.getChannel() == channel) { 
                        MapleCharacter other = Server.getInstance().getWorld(world).getChannel(channel).getPlayerStorage().getCharacterByName(partychar.getName()); 
                        if (other != null) { 
                            client.announce(MaplePacketCreator.updatePartyMemberHP(other.getId(), other.getHp(), other.getCurrentMaxHp())); 
                        } 
                    } 
                } 
            } 
        } 

        public void registerEffect(MapleStatEffect effect, long starttime, ScheduledFuture<?schedule) { 
            if (
    effect.isDragonBlood()) { 
                
    prepareDragonBlood(effect); 
            } else if (
    effect.isBerserk()) { 
                
    checkBerserk(); 
            } else if (
    effect.isBeholder()) { 
                final 
    int beholder DarkKnight.BEHOLDER
                if (
    beholderHealingSchedule != null) { 
                    
    beholderHealingSchedule.cancel(false); 
                } 
                if (
    beholderBuffSchedule != null) { 
                    
    beholderBuffSchedule.cancel(false); 
                } 
                
    Skill bHealing SkillFactory.getSkill(DarkKnight.AURA_OF_BEHOLDER); 
                
    int bHealingLvl getSkillLevel(bHealing); 
                if (
    bHealingLvl 0) { 
                    final 
    MapleStatEffect healEffect bHealing.getEffect(bHealingLvl); 
                    
    int healInterval healEffect.getX() * 1000
                    
    beholderHealingSchedule TimerManager.getInstance().register(new Runnable() { 
                       [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    addHP(healEffect.getHp()); 
                            
    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder2)); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.summonSkill(getId(), beholder5), true); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showOwnBuffEffect(beholder2), false); 
                        } 
                    }, 
    healIntervalhealInterval); 
                } 
                
    Skill bBuff SkillFactory.getSkill(DarkKnight.HEX_OF_BEHOLDER); 
                if (
    getSkillLevel(bBuff) > 0) { 
                    final 
    MapleStatEffect buffEffect bBuff.getEffect(getSkillLevel(bBuff)); 
                    
    int buffInterval buffEffect.getX() * 1000
                    
    beholderBuffSchedule TimerManager.getInstance().register(new Runnable() { 
                       [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    buffEffect.applyTo(MapleCharacter.this); 
                            
    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder2)); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.summonSkill(getId(), beholder, (int) (Math.random() * 3) + 6), true); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showBuffeffect(getId(), beholder2), false); 
                        } 
                    }, 
    buffIntervalbuffInterval); 
                } 
            } else if (
    effect.isRecovery()) { 
                final 
    byte heal = (byteeffect.getX(); 
                
    recoveryTask TimerManager.getInstance().register(new Runnable() { 
                   [
    MENTION=2000004426]Override[/MENTION
                    public 
    void run() { 
                        
    addHP(heal); 
                        
    client.announce(MaplePacketCreator.showOwnRecovery(heal)); 
                        
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showRecovery(idheal), false); 
                    } 
                }, 
    50005000); 
            } 
            for (
    Pair<MapleBuffStatIntegerstatup effect.getStatups()) { 
                
    effects.put(statup.getLeft(), new MapleBuffStatValueHolder(effectstarttimeschedulestatup.getRight().intValue())); 
            } 
            
    recalcLocalStats(); 
        } 

        public 
    void removeAllCooldownsExcept(int id) { 
            for (
    MapleCoolDownValueHolder mcvh coolDowns.values()) { 
                if (
    mcvh.skillId != id) { 
                    
    coolDowns.remove(mcvh.skillId); 
                } 
            } 
        } 

        public static 
    void removeAriantRoom(int room) { 
            
    ariantroomleader[room] = ""
            
    ariantroomslot[room] = 0
        } 

        public 
    void removeCooldown(int skillId) { 
            if (
    this.coolDowns.containsKey(skillId)) { 
                
    this.coolDowns.remove(skillId); 
            } 
        } 

        public 
    void removePet(MaplePet petboolean shift_left) { 
            
    int slot = -1
            for (
    int i 03i++) { 
                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 slot3i++) { 
                        if (
    != 2) { 
                            
    pets[i] = pets[1]; 
                        } else { 
                            
    pets[i] = null
                        } 
                    } 
                } 
            } 
        } 

        public 
    void removeVisibleMapObject(MapleMapObject mo) { 
            
    visibleMapObjects.remove(mo); 
        } 

        public 
    void resetStats() { 
            List<
    Pair<MapleStatInteger>> statup = new ArrayList<>(5); 
            
    int tap 0tsp 1
            
    int tstr 4tdex 4tint 4tluk 4
            
    int levelap = (isCygnus() ? 5); 
            switch (
    job.getId()) { 
                case 
    100
                case 
    1100
                case 
    2100:// ? 
                    
    tstr 35
                    
    tap = ((getLevel() - 10) * levelap) + 14
                    
    tsp += ((getLevel() - 10) * 3); 
                    break; 
                case 
    200
                case 
    1200
                    
    tint 20
                    
    tap = ((getLevel() - 8) * levelap) + 29
                    
    tsp += ((getLevel() - 8) * 3); 
                    break; 
                case 
    300
                case 
    1300
                case 
    400
                case 
    1400
                    
    tdex 25
                    
    tap = ((getLevel() - 10) * levelap) + 24
                    
    tsp += ((getLevel() - 10) * 3); 
                    break; 
                case 
    500
                case 
    1500
                    
    tdex 20
                    
    tap = ((getLevel() - 10) * levelap) + 29
                    
    tsp += ((getLevel() - 10) * 3); 
                    break; 
            } 
            
    this.remainingAp tap
            
    this.remainingSp tsp
            
    this.dex tdex
            
    this.int_ tint
            
    this.str tstr
            
    this.luk tluk
            
    statup.add(new Pair<>(MapleStat.AVAILABLEAPtap)); 
            
    statup.add(new Pair<>(MapleStat.AVAILABLESPtsp)); 
            
    statup.add(new Pair<>(MapleStat.STRtstr)); 
            
    statup.add(new Pair<>(MapleStat.DEXtdex)); 
            
    statup.add(new Pair<>(MapleStat.INTtint)); 
            
    statup.add(new Pair<>(MapleStat.LUKtluk)); 
            
    announce(MaplePacketCreator.updatePlayerStats(statup)); 
        } 

        public 
    void resetBattleshipHp() { 
            
    this.battleshipHp 4000 getSkillLevel(SkillFactory.getSkill(Corsair.BATTLE_SHIP)) + ((getLevel() - 120) * 2000); 
        } 

        public 
    void resetEnteredScript() { 
            if (
    entered.containsKey(map.getId())) { 
                
    entered.remove(map.getId()); 
            } 
        } 

        public 
    void resetEnteredScript(int mapId) { 
            if (
    entered.containsKey(mapId)) { 
                
    entered.remove(mapId); 
            } 
        } 

        public 
    void resetEnteredScript(String script) { 
            for (
    int mapId entered.keySet()) { 
                if (
    entered.get(mapId).equals(script)) { 
                    
    entered.remove(mapId); 
                } 
            } 
        } 

        public 
    void resetMGC() { 
            
    this.mgc null
        } 

        public 
    void saveCooldowns() { 
            if (
    getAllCooldowns().size() > 0) { 
                try { 
                    
    Connection con DatabaseConnection.getConnection(); 
                    
    deleteWhereCharacterId(con"DELETE FROM cooldowns WHERE charid = ?"); 
                    try (
    PreparedStatement ps con.prepareStatement("INSERT INTO cooldowns (charid, SkillID, StartTime, length) VALUES (?, ?, ?, ?)")) { 
                        
    ps.setInt(1getId()); 
                        for (
    PlayerCoolDownValueHolder cooling getAllCooldowns()) { 
                            
    ps.setInt(2cooling.skillId); 
                            
    ps.setLong(3cooling.startTime); 
                            
    ps.setLong(4cooling.length); 
                            
    ps.addBatch(); 
                        } 
                        
    ps.executeBatch(); 
                    } 
                } catch (
    SQLException se) { 
                } 
            } 
        } 

        public 
    void saveGuildStatus() { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET guildid = ?, guildrank = ?, allianceRank = ? WHERE id = ?")) { 
                    
    ps.setInt(1guildid); 
                    
    ps.setInt(2guildrank); 
                    
    ps.setInt(3allianceRank); 
                    
    ps.setInt(4id); 
                    
    ps.execute(); 
                } 
            } catch (
    SQLException se) { 
            } 
        } 

        public 
    void saveLocation(String type) { 
            
    MaplePortal closest map.findClosestPortal(getPosition()); 
            
    savedLocations[SavedLocationType.fromString(type).ordinal()] = new SavedLocation(getMapId(), closest != null closest.getId() : 0); 
        } 

        public final 
    boolean saveNewCharToDB() { 
            final 
    Connection con DatabaseConnection.getConnection(); 
            
    PreparedStatement ps null

            try { 
                
    con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); 
                
    con.setAutoCommit(false); 
                
    ps con.prepareStatement("INSERT INTO characters (str, dex, luk, `int`, gm, skincolor, gender, job, hair, face, map, meso, spawnpoint, accountid, name, world, equipslots, useslots, setupslots, etcslots, occuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"DatabaseConnection.RETURN_GENERATED_KEYS); 
                
    ps.setInt(112); 
                
    ps.setInt(25); 
                
    ps.setInt(34); 
                
    ps.setInt(44); 
                
    ps.setInt(5gmLevel); 
                
    ps.setInt(6skinColor.getId()); 
                
    ps.setInt(7gender); 
                
    ps.setInt(8getJob().getId()); 
                
    ps.setInt(9hair); 
                
    ps.setInt(10face); 
                
    ps.setInt(11mapid); 
                
    ps.setInt(12Math.abs(meso.get())); 
                
    ps.setInt(130); 
                
    ps.setInt(14accountid); 
                
    ps.setString(15name); 
                
    ps.setInt(16world); 
                
    ps.setInt(1796); 
                
    ps.setInt(1896); 
                
    ps.setInt(1996); 
                
    ps.setInt(2096); 
                
    ps.setInt(21, -1); 
                
    int updateRows ps.executeUpdate(); 
                if (
    updateRows 1) { 
                    
    ps.close(); 
                    
    FilePrinter.printError(FilePrinter.INSERT_CHAR"Error trying to insert " name); 
                    return 
    false
                } 
                
    ResultSet rs ps.getGeneratedKeys(); 
                if (
    rs.next()) { 
                    
    this.id rs.getInt(1); 
                    
    rs.close(); 
                    
    ps.close(); 
                } else { 
                    
    rs.close(); 
                    
    ps.close(); 
                    
    FilePrinter.printError(FilePrinter.INSERT_CHAR"Inserting char failed " name); 
                    return 
    false
                    
    // throw new RuntimeException("Inserting char failed."); 
                


                
    ps con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    int i 0DEFAULT_KEY.lengthi++) { 
                    
    ps.setInt(2DEFAULT_KEY[i]); 
                    
    ps.setInt(3DEFAULT_TYPE[i]); 
                    
    ps.setInt(4DEFAULT_ACTION[i]); 
                    
    ps.execute(); 
                } 
                
    ps.close(); 

                final List<
    Pair<ItemMapleInventoryType>> itemsWithType = new ArrayList<>(); 

                for (
    MapleInventory iv inventory) { 
                    for (
    Item item iv.list()) { 
                        
    itemsWithType.add(new Pair<>(itemiv.getType())); 
                    } 
                } 

                
    ItemFactory.INVENTORY.saveItems(itemsWithTypeid); 

                
    /* 
                 * //jobs start with skills :| 
                 * ps = con.prepareStatement("INSERT INTO skills (characterid, skillid, skilllevel, masterlevel, expiration) VALUES (?, ?, ?, ?, ?)"); 
                 * ps.setInt(1, id); 
                 * for (final Entry<Skill, SkillEntry> skill : skills.entrySet()) { 
                 * ps.setInt(2, skill.getKey().getId()); 
                 * ps.setInt(3, skill.getValue().skillevel); 
                 * ps.setInt(4, skill.getValue().masterlevel); 
                 * ps.setLong(5, skill.getValue().expiration); 
                 * ps.execute(); 
                 * } 
                 * ps.close(); 
                 *  
                 * //sometimes starts with quests too :| 
                 * ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `forfeited`) VALUES (DEFAULT, ?, ?, ?, ?, ?)", DatabaseConnection.RETURN_GENERATED_KEYS); 
                 * try (PreparedStatement pse = con.prepareStatement("INSERT INTO questprogress VALUES (DEFAULT, ?, ?, ?)")) { 
                 * ps.setInt(1, id); 
                 * for (MapleQuestStatus q : quests.values()) { 
                 * ps.setInt(2, q.getQuest().getId()); 
                 * ps.setInt(3, q.getStatus().getId()); 
                 * ps.setLong(4, q.getCompletionTime()); 
                 * ps.setInt(5, q.getForfeited()); 
                 * ps.executeUpdate(); 
                 * try (ResultSet rse = ps.getGeneratedKeys()) { 
                 * rse.next(); 
                 * for (int mob : q.getProgress().keySet()) { 
                 * pse.setInt(1, rse.getInt(1)); 
                 * pse.setInt(2, mob); 
                 * pse.setString(3, q.getProgress(mob)); 
                 * pse.addBatch(); 
                 * } 
                 * pse.executeBatch(); 
                 * } 
                 * } 
                 * } don't think this is needed for v83 
                 */ 

                
    con.commit(); 
                return 
    true
            } catch (
    Throwable t) { 
                
    System.out.println(t); 
                
    FilePrinter.printError(FilePrinter.INSERT_CHARt"Error creating " name " Level: " level " Job: " job.getId()); 
                try { 
                    
    con.rollback(); 
                } catch (
    SQLException se) { 
                    
    FilePrinter.printError(FilePrinter.INSERT_CHARse"Error trying to rollback " name); 
                } 
                return 
    false
            } finally { 
                try { 
                    if (
    ps != null && !ps.isClosed()) { 
                        
    ps.close(); 
                    } 
                    
    con.setAutoCommit(true); 
                    
    con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); 
                } catch (
    SQLException e) { 
                } 
            } 
        } 

        public 
    void saveToDB() { 
            
    Connection con DatabaseConnection.getConnection(); 
            try { 
                
    con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); 
                
    con.setAutoCommit(false); 
                
    PreparedStatement ps
                
    ps con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, gachaexp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpMpUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, mountlevel = ?, mountexp = ?, mounttiredness= ?, equipslots = ?, useslots = ?, setupslots = ?, etcslots = ?,  monsterbookcover = ?, vanquisherStage = ?, dojoPoints = ?, lastDojoStage = ?, finishedDojoTutorial = ?, vanquisherKills = ?, matchcardwins = ?, matchcardlosses = ?, matchcardties = ?, omokwins = ?, omoklosses = ?, omokties = ?, reborns = ?, name = ?, jumppoints = ?, jailed = ?, jailtime = ?, jailduration = ?, eventpoints = ?, occuid = ?, occulevel = ?, occuexp = ?, legend = ?, horntail_slyed = ?, pinkbeen_slyed = ? WHERE id = ?"Statement.RETURN_GENERATED_KEYS); // horntail_slyed = ?, pinkbeen_slyed = ?, 
                
    if (gmLevel && level 199) { 
                    
    ps.setInt(1isCygnus() ? 120 200); 
                } else { 
                    
    ps.setInt(1level); 
                } 
                
    ps.setInt(2fame); 
                
    ps.setInt(3str); 
                
    ps.setInt(4dex); 
                
    ps.setInt(5luk); 
                
    ps.setInt(6int_); 
                
    ps.setInt(7Math.abs(exp.get())); 
                
    ps.setInt(8Math.abs(gachaexp.get())); 
                
    ps.setInt(9hp); 
                
    ps.setInt(10mp); 
                
    ps.setInt(11maxhp); 
                
    ps.setInt(12maxmp); 
                
    ps.setInt(13remainingSp); 
                
    ps.setInt(14remainingAp); 
                
    ps.setInt(15gmLevel); 
                
    ps.setInt(16skinColor.getId()); 
                
    ps.setInt(17gender); 
                
    ps.setInt(18job.getId()); 
                
    ps.setInt(19hair); 
                
    ps.setInt(20face); 
                if (
    map == null || (cashshop != null && cashshop.isOpened())) { 
                    
    ps.setInt(21mapid); 
                } else { 
                    if (
    map.getForcedReturnId() != 999999999) { 
                        
    ps.setInt(21map.getForcedReturnId()); 
                    } else { 
                        
    ps.setInt(21getHp() < map.getReturnMapId() : map.getId()); 
                    } 
                } 
                
    ps.setInt(22meso.get()); 
                
    ps.setInt(23hpMpApUsed); 
                if (
    map == null || map.getId() == 610020000 || map.getId() == 610020001) { 
                    
    ps.setInt(240); 
                } else { 
                    
    MaplePortal closest map.findClosestSpawnpoint(getPosition()); 
                    if (
    closest != null) { 
                        
    ps.setInt(24closest.getId()); 
                    } else { 
                        
    ps.setInt(240); 
                    } 
                } 
                if (
    party != null) { 
                    
    ps.setInt(25party.getId()); 
                } else { 
                    
    ps.setInt(25, -1); 
                } 
                
    ps.setInt(26buddylist.getCapacity()); 
                if (
    messenger != null) { 
                    
    ps.setInt(27messenger.getId()); 
                    
    ps.setInt(28messengerposition); 
                } else { 
                    
    ps.setInt(270); 
                    
    ps.setInt(284); 
                } 
                if (
    maplemount != null) { 
                    
    ps.setInt(29maplemount.getLevel()); 
                    
    ps.setInt(30maplemount.getExp()); 
                    
    ps.setInt(31maplemount.getTiredness()); 
                } else { 
                    
    ps.setInt(291); 
                    
    ps.setInt(300); 
                    
    ps.setInt(310); 
                } 
                for (
    int i 15i++) { 
                    
    ps.setInt(31getSlots(i)); 
                } 

                
    monsterbook.saveCards(getId()); 

                
    ps.setInt(36bookCover); 
                
    ps.setInt(37vanquisherStage); 
                
    ps.setInt(38dojoPoints); 
                
    ps.setInt(39dojoStage); 
                
    ps.setInt(40finishedDojoTutorial 0); 
                
    ps.setInt(41vanquisherKills); 
                
    ps.setInt(42matchcardwins); 
                
    ps.setInt(43matchcardlosses); 
                
    ps.setInt(44matchcardties); 
                
    ps.setInt(45omokwins); 
                
    ps.setInt(46omoklosses); 
                
    ps.setInt(47omokties); 
                
    ps.setInt(48reborns); 
                
    ps.setString(49name); 
                
    ps.setInt(50jumppoints); 
                
    ps.setBoolean(51jailed); 
                
    ps.setLong(52jailtime); 
                
    ps.setLong(53jailduration); 
                
    ps.setInt(54eventpoints); 
                
    ps.setInt(55occupation != null occupation.getInfo().getId() : -1); 
                
    ps.setInt(56occupation != null occupation.getLevel() : 0); 
                
    ps.setInt(57occupation != null occupation.getExp() : 0); 
                            
    ps.setInt(58legend); 
                            
    ps.setInt(59horntail_slyed); 
                            
    ps.setInt(60pinkbeen_slyed); 
                            
    ps.setInt(61id); 

                
    int updateRows ps.executeUpdate(); 
                if (
    updateRows 1) { 
                    throw new 
    RuntimeException("Character not in database (" id ")"); 
                } 
                for (
    int i 03i++) { 
                    if (
    pets[i] != null) { 
                        
    pets[i].saveToDb(); 
                    } 
                } 
                
    deleteWhereCharacterId(con"DELETE FROM keymap WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    Entry<IntegerMapleKeyBindingkeybinding keymap.entrySet()) { 
                    
    ps.setInt(2keybinding.getKey().intValue()); 
                    
    ps.setInt(3keybinding.getValue().getType()); 
                    
    ps.setInt(4keybinding.getValue().getAction()); 
                    
    ps.addBatch(); 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM skillmacros WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO skillmacros (characterid, skill1, skill2, skill3, name, shout, position) VALUES (?, ?, ?, ?, ?, ?, ?)"); 
                
    ps.setInt(1getId()); 
                for (
    int i 05i++) { 
                    
    SkillMacro macro skillMacros[i]; 
                    if (
    macro != null) { 
                        
    ps.setInt(2macro.getSkill1()); 
                        
    ps.setInt(3macro.getSkill2()); 
                        
    ps.setInt(4macro.getSkill3()); 
                        
    ps.setString(5macro.getName()); 
                        
    ps.setInt(6macro.getShout()); 
                        
    ps.setInt(7i); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                List<
    Pair<ItemMapleInventoryType>> itemsWithType = new ArrayList<>(); 

                for (
    MapleInventory iv inventory) { 
                    for (
    Item item iv.list()) { 
                        
    itemsWithType.add(new Pair<>(itemiv.getType())); 
                    } 
                } 

                
    ItemFactory.INVENTORY.saveItems(itemsWithTypeid); 
                
    deleteWhereCharacterId(con"DELETE FROM skills WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO skills (characterid, skillid, skilllevel, masterlevel, expiration) VALUES (?, ?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    Entry<SkillSkillEntryskill skills.entrySet()) { 
                    
    ps.setInt(2skill.getKey().getId()); 
                    
    ps.setInt(3skill.getValue().skillevel); 
                    
    ps.setInt(4skill.getValue().masterlevel); 
                    
    ps.setLong(5skill.getValue().expiration); 
                    
    ps.addBatch(); 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM savedlocations WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO savedlocations (characterid, `locationtype`, `map`, `portal`) VALUES (?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    SavedLocationType savedLocationType SavedLocationType.values()) { 
                    if (
    savedLocations[savedLocationType.ordinal()] != null) { 
                        
    ps.setString(2savedLocationType.name()); 
                        
    ps.setInt(3savedLocations[savedLocationType.ordinal()].getMapId()); 
                        
    ps.setInt(4savedLocations[savedLocationType.ordinal()].getPortal()); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM trocklocations WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 0)"); 
                for (
    int i 0getTrockSize(); i++) { 
                    if (
    trockmaps[i] != 999999999) { 
                        
    ps.setInt(1getId()); 
                        
    ps.setInt(2trockmaps[i]); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    ps con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 1)"); 
                for (
    int i 0getVipTrockSize(); i++) { 
                    if (
    viptrockmaps[i] != 999999999) { 
                        
    ps.setInt(1getId()); 
                        
    ps.setInt(2viptrockmaps[i]); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM buddies WHERE characterid = ? AND pending = 0"); 
                
    ps con.prepareStatement("INSERT INTO buddies (characterid, `buddyid`, `pending`, `group`) VALUES (?, ?, 0, ?)"); 
                
    ps.setInt(1id); 
                for (
    BuddylistEntry entry buddylist.getBuddies()) { 
                    if (
    entry.isVisible()) { 
                        
    ps.setInt(2entry.getCharacterId()); 
                        
    ps.setString(3entry.getGroup()); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM area_info WHERE charid = ?"); 
                
    ps con.prepareStatement("INSERT INTO area_info (id, charid, area, info) VALUES (DEFAULT, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    Entry<ShortStringarea area_info.entrySet()) { 
                    
    ps.setInt(2area.getKey()); 
                    
    ps.setString(3area.getValue()); 
                    
    ps.addBatch(); 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM eventstats WHERE characterid = ?"); 
                
    deleteWhereCharacterId(con"DELETE FROM queststatus WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `forfeited`) VALUES (DEFAULT, ?, ?, ?, ?, ?)"Statement.RETURN_GENERATED_KEYS); 
                
    PreparedStatement psf
                try (
    PreparedStatement pse con.prepareStatement("INSERT INTO questprogress VALUES (DEFAULT, ?, ?, ?)")) { 
                    
    psf con.prepareStatement("INSERT INTO medalmaps VALUES (DEFAULT, ?, ?)"); 
                    
    ps.setInt(1id); 
                    for (
    MapleQuestStatus q quests.values()) { 
                        
    ps.setInt(2q.getQuest().getId()); 
                        
    ps.setInt(3q.getStatus().getId()); 
                        
    ps.setInt(4, (int) (q.getCompletionTime() / 1000)); 
                        
    ps.setInt(5q.getForfeited()); 
                        
    ps.executeUpdate(); 
                        try (
    ResultSet rs ps.getGeneratedKeys()) { 
                            
    rs.next(); 
                            for (
    int mob q.getProgress().keySet()) { 
                                
    pse.setInt(1rs.getInt(1)); 
                                
    pse.setInt(2mob); 
                                
    pse.setString(3q.getProgress(mob)); 
                                
    pse.addBatch(); 
                            } 
                            for (
    int i 0q.getMedalMaps().size(); i++) { 
                                
    psf.setInt(1rs.getInt(1)); 
                                
    psf.setInt(2q.getMedalMaps().get(i)); 
                                
    psf.addBatch(); 
                            } 
                            
    pse.executeBatch(); 
                            
    psf.executeBatch(); 
                        } 
                    } 
                } 
                
    psf.close(); 

                
    deleteWhereCharacterId(con"DELETE FROM customQuestStatus WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO customQuestStatus (`id`, `characterid`, `quest`, `status`, `time`, `customData`) VALUES (DEFAULT, ?, ?, ?, ?, ?)"Statement.RETURN_GENERATED_KEYS); 
                
    PreparedStatement pse con.prepareStatement("INSERT INTO customQuestMobs VALUES (DEFAULT, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (final 
    MapleCustomQuestStatus q customQuests.values()) { 
                    
    ps.setInt(2q.getQuest().getQuestId()); 
                    
    ps.setInt(3q.getStatus()); 
                    
    ps.setInt(4, (int) (q.getCompletionTime() / 1000)); 
                    
    ps.setString(5q.getCustomData()); 
                    
    ps.executeUpdate(); 
                    
    ResultSet rs ps.getGeneratedKeys(); 
                    
    rs.next(); 

                    if (
    q.hasMobKills()) { 
                        for (
    int mob q.getMobKills().keySet()) { 
                            
    pse.setInt(1rs.getInt(1)); 
                            
    pse.setInt(2mob); 
                            
    pse.setInt(3q.getMobKills(mob)); 
                            
    pse.executeUpdate(); 
                        } 
                    } 
                    
    rs.close(); 
                } 
                
    ps.close(); 
                
    pse.close(); 

                
    ps con.prepareStatement("UPDATE accounts SET gm = ? WHERE id = ?"); 
                
    ps.setInt(1gmLevel); 
                
    ps.setInt(2client.getAccID()); 
                
    ps.executeUpdate(); 
                if (
    cashshop != null) { 
                    
    cashshop.save(); 
                } 
                if (
    storage != null) { 
                    
    storage.saveToDB(); 
                } 
                
    ps.close(); 
                
    con.commit(); 
            } catch (
    SQLException RuntimeException t) { 
                
    FilePrinter.printError(FilePrinter.SAVE_CHARt"Error saving " name " Level: " level " Job: " job.getId()); 
                try { 
                    
    con.rollback(); 
                } catch (
    SQLException se) { 
                    
    FilePrinter.printError(FilePrinter.SAVE_CHARse"Error trying to rollback " name); 
                } 
            } finally { 
                try { 
                    
    con.setAutoCommit(true); 
                    
    con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); 
                } catch (
    Exception e) { 
                } 
            } 
        } 

        public 
    void sendPolice(String reasonint duration) { 
            
    announce(MaplePacketCreator.sendPolice("You have been banned from " ServerConstants.SERVER_NAME ".")); 
            
    this.isbanned true
            
    TimerManager.getInstance().schedule(new Runnable() { 
               [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    client.disconnect(falsefalse); // FAGGOTS 
                

            }, 
    duration); 
        } 

        public 
    void sendPolice(String text) { 
            
    announce(MaplePacketCreator.sendPolice(text)); 
            
    this.isbanned true
            
    TimerManager.getInstance().schedule(new Runnable() { 
               [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    client.disconnect(falsefalse); // FAGGOTS 
                

            }, 
    6000); 
        } 

        public 
    void sendKeymap() { 
            
    client.announce(MaplePacketCreator.getKeymap(keymap)); 
        } 

        public 
    void sendMacros() { 
            
    boolean macros false
            for (
    int i 05i++) { 
                if (
    skillMacros[i] != null) { 
                    
    macros true
                } 
            } 
            if (
    macros) { 
                
    client.announce(MaplePacketCreator.getMacros(skillMacros)); 
            } 
        } 

        public 
    void sendNote(String toString msgbyte famethrows SQLException 
            try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("INSERT INTO notes (`to`, `from`, `message`, `timestamp`, `fame`) VALUES (?, ?, ?, ?, ?)"Statement.RETURN_GENERATED_KEYS)) { 
                
    ps.setString(1to); 
                
    ps.setString(2this.getName()); 
                
    ps.setString(3msg); 
                
    ps.setLong(4System.currentTimeMillis()); 
                
    ps.setByte(5fame); 
                
    ps.executeUpdate(); 
            } 
        } 

        public 
    void setAllianceRank(int rank) { 
            
    allianceRank rank
            if (
    mgc != null) { 
                
    mgc.setAllianceRank(rank); 
            } 
        } 

        public 
    void setAllowWarpToId(int id) { 
            
    this.warpToId id
        } 

        public static 
    void setAriantRoomLeader(int roomString charname) { 
            
    ariantroomleader[room] = charname
        } 

        public static 
    void setAriantSlotRoom(int roomint slot) { 
            
    ariantroomslot[room] = slot
        } 

        public 
    void setBattleshipHp(int battleshipHp) { 
            
    this.battleshipHp battleshipHp
        } 

        public 
    void setBuddyCapacity(int capacity) { 
            
    buddylist.setCapacity(capacity); 
            
    client.announce(MaplePacketCreator.updateBuddyCapacity(capacity)); 
        } 

        public 
    void setBuffedValue(MapleBuffStat effectint value) { 
            
    MapleBuffStatValueHolder mbsvh effects.get(effect); 
            if (
    mbsvh == null) { 
                return; 
            } 
            
    mbsvh.value value
        } 

        public 
    void setChair(int chair) { 
            
    this.chair chair
        } 

        public 
    void setChalkboard(String text) { 
            
    this.chalktext text
        } 

        public 
    void setDex(int dex) { 
            
    this.dex dex
            
    recalcLocalStats(); 
        } 

        public 
    void setDojoEnergy(int x) { 
            
    this.dojoEnergy x
        } 

        public 
    void setDojoParty(boolean b) { 
            
    this.dojoParty b
        } 

        public 
    void setDojoPoints(int x) { 
            
    this.dojoPoints x
        } 

        public 
    void setDojoStage(int x) { 
            
    this.dojoStage x
        } 

        public 
    void setDojoStart() { 
            
    this.dojoMap map
            
    int stage = (map.getId() / 100) % 100
            
    this.dojoFinish System.currentTimeMillis() + (stage 36 15 stage 5) * 60000
        } 

        public 
    void setRates() { 
            
    /* 
             * Calendar cal = Calendar.getInstance(); 
             * cal.setTimeZone(TimeZone.getTimeZone("GMT-8")); 
             * int hr = cal.get(Calendar.HOUR_OF_DAY); 
             * if ((haveItem(5360001) && hr > 6 && hr < 12) || (haveItem(5360002) && hr > 9 && hr < 15) || (haveItem(536000) && hr > 12 && hr < 18) || (haveItem(5360004) && hr > 15 && hr < 21) || (haveItem(536000) && hr > 18) || (haveItem(5360006) && hr < 5) || (haveItem(5360007) && hr > 2 && hr < 6) || (haveItem(5360008) && hr >= 6 && hr < 11)) { 
             * this.dropRate = 2 * worldz.getDropRate(); 
             * this.mesoRate = 2 * worldz.getMesoRate(); 
             * } else { 
             * this.dropRate = worldz.getDropRate(); 
             * this.mesoRate = worldz.getMesoRate(); 
             * } 
             * if ((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) || haveItem(5211048)) { 
             * if (isBeginnerJob()) { 
             * this.expRate = 2; 
             * } else { 
             * this.expRate = 2 * worldz.getExpRate(); 
             * } 
             * } else { 
             * if (isBeginnerJob()) { 
             * this.expRate = 1; 
             * } else { 
             * this.expRate = worldz.getExpRate(); 
             * } 
             * } 
             */ 

            
    World worldz Server.getInstance().getWorld(world); 
            
    this.expRate worldz.getExpRate(); 
            
    this.mesoRate worldz.getMesoRate(); 
            
    this.dropRate worldz.getDropRate(); 
        } 

        public 
    void setEnergyBar(int set) { 
            
    energybar set
        } 

        public 
    void setEventInstance(EventInstanceManager eventInstance) { 
            
    this.eventInstance eventInstance
        } 

        public 
    void setExp(int amount) { 
            
    this.exp.set(amount); 
        } 

        public 
    void setGachaExp(int amount) { 
            
    this.gachaexp.set(amount); 
        } 

        public 
    void setFace(int face) { 
            
    this.face face
        } 

        public 
    void setFame(int fame) { 
            
    this.fame fame
        } 

        public 
    void setFamilyId(int familyId) { 
            
    this.familyId familyId
        } 

        public 
    void setFinishedDojoTutorial() { 
            
    this.finishedDojoTutorial true
        } 

        public 
    void setGender(int gender) { 
            
    this.gender gender
        } 

        public 
    void setGM(int level) { 
            
    this.gmLevel level
        } 

        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 setHair(int hair) { 
            
    this.hair hair
        } 

        public 
    void setHasMerchant(boolean set) { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = ? WHERE id = ?")) { 
                    
    ps.setInt(1set 0); 
                    
    ps.setInt(2id); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
                
    e.printStackTrace(); 
            } 
            
    hasMerchant set
        } 

        public 
    void addMerchantMesos(int add) { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?"Statement.RETURN_GENERATED_KEYS)) { 
                    
    ps.setInt(1merchantmeso add); 
                    
    ps.setInt(2id); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
                return; 
            } 
            
    merchantmeso += add
        } 

        public 
    void setMerchantMeso(int set) { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?"Statement.RETURN_GENERATED_KEYS)) { 
                    
    ps.setInt(1set); 
                    
    ps.setInt(2id); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
                return; 
            } 
            
    merchantmeso set
        } 

        public 
    void setHiredMerchant(HiredMerchant merchant) { 
            
    this.hiredMerchant merchant
        } 

        public 
    void setHp(int newhp) { 
            
    setHp(newhpfalse); 
        } 

        public 
    void setHp(int newhpboolean silent) { 
            
    int oldHp hp
            
    int thp newhp
            if (
    thp 0) { 
                
    thp 0
            } 
            if (
    thp localmaxhp) { 
                
    thp localmaxhp
            } 
            
    this.hp thp
            if (!
    silent) { 
                
    updatePartyMemberHP(); 
            } 
            if (
    oldHp hp && !isAlive()) { 
                
    playerDead(); 
            } 
        } 

        public 
    void setHpMpApUsed(int mpApUsed) { 
            
    this.hpMpApUsed mpApUsed
        } 

        public 
    void setHpMp(int x) { 
            
    setHp(x); 
            
    setMp(x); 
            
    updateSingleStat(MapleStat.HPhp); 
            
    updateSingleStat(MapleStat.MPmp); 
        } 

        public 
    void setInt(int int_) { 
            
    this.int_ int_
            
    recalcLocalStats(); 
        } 

        public 
    void setInventory(MapleInventoryType typeMapleInventory inv) { 
            
    inventory[type.ordinal()] = inv
        } 

        public 
    void setItemEffect(int itemEffect) { 
            
    this.itemEffect itemEffect
        } 

        public 
    void setJob(MapleJob job) { 
            
    this.job job
        } 

        public 
    void setLastHealed(long time) { 
            
    this.lastHealed time
        } 

        public 
    void setLastUsedCashItem(long time) { 
            
    this.lastUsedCashItem time
        } 

        public 
    void setLevel(int level) { 
            
    this.level level
        } 

        public 
    void setLuk(int luk) { 
            
    this.luk luk
            
    recalcLocalStats(); 
        } 

        public 
    void setMap(int PmapId) { 
            
    this.mapid PmapId
        } 

        public 
    void setMap(MapleMap newmap) { 
            
    this.map newmap
        } 

        public 
    void setMarkedMonster(int markedMonster) { 
            
    this.markedMonster markedMonster
        } 

        public 
    void setMaxHp(int hp) { 
            
    this.maxhp hp
            
    recalcLocalStats(); 
        } 

        public 
    void setMaxHp(int hpboolean ap) { 
            
    hp Math.min(30000hp); 
            if (
    ap) { 
                
    setHpMpApUsed(getHpMpApUsed() + 1); 
            } 
            
    this.maxhp hp
            
    recalcLocalStats(); 
        } 

        public 
    void setMaxMp(int mp) { 
            
    this.maxmp mp
            
    recalcLocalStats(); 
        } 

        public 
    void setMaxMp(int mpboolean ap) { 
            
    mp Math.min(30000mp); 
            if (
    ap) { 
                
    setHpMpApUsed(getHpMpApUsed() + 1); 
            } 
            
    this.maxmp mp
            
    recalcLocalStats(); 
        } 

        public 
    void setMessenger(MapleMessenger messenger) { 
            
    this.messenger messenger
        } 

        public 
    void setMessengerPosition(int position) { 
            
    this.messengerposition position
        } 

        public 
    void setMiniGame(AbstractMinigame miniGame) { 
            
    this.miniGame miniGame
        } 

        public 
    void setMiniGamePoints(MapleCharacter visitorint winnerslotboolean omok) { 
            if (
    omok) { 
                if (
    winnerslot == 1) { 
                    
    this.omokwins++; 
                    
    visitor.omoklosses++; 
                } else if (
    winnerslot == 2) { 
                    
    visitor.omokwins++; 
                    
    this.omoklosses++; 
                } else { 
                    
    this.omokties++; 
                    
    visitor.omokties++; 
                } 
            } else { 
                if (
    winnerslot == 1) { 
                    
    this.matchcardwins++; 
                    
    visitor.matchcardlosses++; 
                } else if (
    winnerslot == 2) { 
                    
    visitor.matchcardwins++; 
                    
    this.matchcardlosses++; 
                } else { 
                    
    this.matchcardties++; 
                    
    visitor.matchcardties++; 
                } 
            } 
        } 

        public 
    void setMonsterBookCover(int bookCover) { 
            
    this.bookCover bookCover
        } 

        public 
    void setMp(int newmp) { 
            
    int tmp newmp
            if (
    tmp 0) { 
                
    tmp 0
            } 
            if (
    tmp localmaxmp) { 
                
    tmp localmaxmp
            } 
            
    this.mp tmp
        } 

        public 
    void setName(String name) { 
            
    this.name name
        } 

        public 
    void setParty(MapleParty party) { 
            if (
    party == null) { 
                
    this.mpc null
            } 
            
    this.party party
        } 

        public 
    void setPlayerShop(MaplePlayerShop playerShop) { 
            
    this.playerShop playerShop
        } 

        public 
    void setRemainingAp(int remainingAp) { 
            
    this.remainingAp remainingAp
        } 

        public 
    void setRemainingSp(int remainingSp) { 
            
    this.remainingSp remainingSp
        } 

        public 
    void setSearch(String find) { 
            
    search find
        } 

        public 
    void setSkinColor(MapleSkinColor skinColor) { 
            
    this.skinColor skinColor
        } 

        public 
    byte getSlots(int type) { 
            return 
    type == MapleInventoryType.CASH.getType() ? 96 inventory[type].getSlotLimit(); 
        } 

        public 
    boolean gainSlots(int typeint slots) { 
            return 
    gainSlots(typeslotstrue); 
        } 

        public 
    boolean gainSlots(int typeint slotsboolean update) { 
            
    slots += inventory[type].getSlotLimit(); 
            if (
    slots <= 96) { 
                
    inventory[type].setSlotLimit(slots); 

                
    saveToDB(); 
                if (
    update) { 
                    
    client.announce(MaplePacketCreator.updateInventorySlotLimit(typeslots)); 
                } 

                return 
    true
            } 

            return 
    false
        } 

        public 
    void setShop(MapleShop shop) { 
            
    this.shop shop
        } 

        public 
    void setSlot(int slotid) { 
            
    slots slotid
        } 

        public 
    void setStr(int str) { 
            
    this.str str
            
    recalcLocalStats(); 
        } 

        public 
    void setTrade(MapleTrade trade) { 
            
    this.trade trade
        } 

        public 
    void setVanquisherKills(int x) { 
            
    this.vanquisherKills x
        } 

        public 
    void setVanquisherStage(int x) { 
            
    this.vanquisherStage x
        } 

        public 
    void setWorld(int world) { 
            
    this.world world
        } 

        public 
    void shiftPetsRight() { 
            if (
    pets[2] == null) { 
                
    pets[2] = pets[1]; 
                
    pets[1] = pets[0]; 
                
    pets[0] = null
            } 
        } 

        public 
    void showDojoClock() { 
            
    int stage = (map.getId() / 100) % 100
            
    long time
            if (
    stage == 1) { 
                
    time = (stage 36 15 stage 5) * 60
            } else { 
                
    time = (dojoFinish System.currentTimeMillis()) / 1000
            } 
            if (
    stage 0) { 
                
    client.announce(MaplePacketCreator.getClock((int) time)); 
            } 
            
    boolean rightmap true
            
    int clockid = (dojoMap.getId() / 100) % 100
            if (
    map.getId() > clockid || map.getId() < clockid 6) { 
                
    rightmap false
            } 
            final 
    boolean rightMap rightmap// lol 
            
    TimerManager.getInstance().schedule(new Runnable() { 
               [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    if (
    rightMap) { 
                        
    client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(925020000)); 
                    } 
                } 
            }, 
    time 1000 3000); // let the TIMES UP display for 3 seconds, then warp 
        


        public 
    void showNote() { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("SELECT * FROM notes WHERE `to`=? AND `deleted` = 0"ResultSet.TYPE_SCROLL_SENSITIVEResultSet.CONCUR_UPDATABLE)) { 
                    
    ps.setString(1this.getName()); 
                    try (
    ResultSet rs ps.executeQuery()) { 
                        
    rs.last(); 
                        
    int count rs.getRow(); 
                        
    rs.first(); 
                        
    client.announce(MaplePacketCreator.showNotes(rscount)); 
                    } 
                } 
            } catch (
    SQLException e) { 
            } 
        } 

        private 
    void silentEnforceMaxHpMp() { 
            
    setMp(getMp()); 
            
    setHp(getHp(), true); 
        } 

        public 
    void silentGiveBuffs(List<PlayerBuffValueHolderbuffs) { 
            for (
    PlayerBuffValueHolder mbsvh buffs) { 
                
    mbsvh.effect.silentApplyBuff(thismbsvh.startTime); 
            } 
        } 

        public 
    void silentPartyUpdate() { 
            if (
    party != null) { 
                
    Server.getInstance().getWorld(world).updateParty(party.getId(), PartyOperation.SILENT_UPDATEgetMPC()); 
            } 
        } 

        public static class 
    SkillEntry 

            public 
    int masterlevel
            public 
    byte skillevel
            public 
    long expiration

            public 
    SkillEntry(byte skillevelint masterlevellong expiration) { 
                
    this.skillevel skillevel
                
    this.masterlevel masterlevel
                
    this.expiration expiration
            } 

           [
    MENTION=2000004426]Override[/MENTION
            public 
    String toString() { 
                return 
    skillevel ":" masterlevel
            } 
        } 

        public 
    boolean skillisCooling(int skillId) { 
            return 
    coolDowns.containsKey(Integer.valueOf(skillId)); 
        } 

        public 
    void startFullnessSchedule(final int decrease, final MaplePet petint petSlot) { 
            
    ScheduledFuture<?> schedule; 
            schedule = TimerManager.getInstance().register(new Runnable() { 
               [MENTION=2000004426]Override[/MENTION] 
                public void run() { 
                    int newFullness = pet.getFullness() - decrease; 
                    if (newFullness <= 5) { 
                        pet.setFullness(15); 
                        pet.saveToDb(); 
                        unequipPet(pet, true); 
                    } else { 
                        pet.setFullness(newFullness); 
                        pet.saveToDb(); 
                        Item petz = getInventory(MapleInventoryType.CASH).getItem(pet.getPosition()); 
                        forceUpdateItem(petz); 
                    } 
                } 
            }, 180000, 18000); 
            fullnessSchedule[petSlot] = schedule; 

        } 

        public void startMapEffect(String msg, int itemId) { 
            startMapEffect(msg, itemId, 30000); 
        } 

        public void startMapEffect(String msg, int itemId, int duration) { 
            final MapleMapEffect mapEffect = new MapleMapEffect(msg, itemId); 
            getClient().announce(mapEffect.makeStartData()); 
            TimerManager.getInstance().schedule(new Runnable() { 
               [MENTION=2000004426]Override[/MENTION] 
                public void run() { 
                    getClient().announce(mapEffect.makeDestroyData()); 
                } 
            }, duration); 
        } 

        public void stopControllingMonster(MapleMonster monster) { 
            controlled.remove(monster); 
        } 

        public void unequipAllPets() { 
            for (int i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    unequipPet(pets[i], true); 
                } 
            } 
        } 

        public void unequipPet(MaplePet pet, boolean shift_left) { 
            unequipPet(pet, shift_left, false); 
        } 

        public void unequipPet(MaplePet pet, boolean shift_left, boolean hunger) { 
            if (this.getPet(this.getPetIndex(pet)) != null) { 
                this.getPet(this.getPetIndex(pet)).setSummoned(false); 
                this.getPet(this.getPetIndex(pet)).saveToDb(); 
            } 
            cancelFullnessSchedule(getPetIndex(pet)); 
            getMap().broadcastMessage(this, MaplePacketCreator.showPet(this, pet, true, hunger), true); 
            client.announce(MaplePacketCreator.petStatUpdate(this)); 
            client.announce(MaplePacketCreator.enableActions()); 
            removePet(pet, shift_left); 
        } 

        public void updateMacros(int position, SkillMacro updateMacro) { 
            skillMacros[position] = updateMacro; 
        } 

        public void updatePartyMemberHP() { 
            if (party != null) { 
                int channel = client.getChannel(); 
                for (MaplePartyCharacter partychar : party.getMembers()) { 
                    if (partychar.getMapId() == getMapId() && partychar.getChannel() == channel) { 
                        MapleCharacter other = Server.getInstance().getWorld(world).getChannel(channel).getPlayerStorage().getCharacterByName(partychar.getName()); 
                        if (other != null) { 
                            other.client.announce(MaplePacketCreator.updatePartyMemberHP(getId(), this.hp, maxhp)); 
                        } 
                    } 
                } 
            } 
        } 

        public void updateQuest(MapleQuestStatus quest) { 
            quests.put(quest.getQuest(), quest); 
            if (quest.getStatus().equals(MapleQuestStatus.Status.STARTED)) { 
                announce(MaplePacketCreator.questProgress((short) quest.getQuest().getId(), quest.getProgress(0))); 
                if (quest.getQuest().getInfoNumber() > 0) { 
                    announce(MaplePacketCreator.questProgress(quest.getQuest().getInfoNumber(), Integer.toString(quest.getMedalProgress()))); 
                } 
                announce(MaplePacketCreator.updateQuestInfo((short) quest.getQuest().getId(), quest.getNpc())); 
            } else if (quest.getStatus().equals(MapleQuestStatus.Status.COMPLETED)) { 
                announce(MaplePacketCreator.completeQuest((short) quest.getQuest().getId(), quest.getCompletionTime())); 
            } else if (quest.getStatus().equals(MapleQuestStatus.Status.NOT_STARTED)) { 
                announce(MaplePacketCreator.forfeitQuest((short) quest.getQuest().getId())); 
            } 
        } 

        public void questTimeLimit(final MapleQuest quest, int time) { 
            ScheduledFuture<?sf TimerManager.getInstance().schedule(new Runnable() { 
               [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    announce(MaplePacketCreator.questExpire(quest.getId())); 
                    
    MapleQuestStatus newStatus = new MapleQuestStatus(questMapleQuestStatus.Status.NOT_STARTED); 
                    
    newStatus.setForfeited(getQuest(quest).getForfeited() + 1); 
                    
    updateQuest(newStatus); 
                } 
            }, 
    time); 
            
    announce(MaplePacketCreator.addQuestTimeLimit(quest.getId(), time)); 
            
    timers.add(sf); 
        } 

        public 
    void updateSingleStat(MapleStat statint newval) { 
            
    updateSingleStat(statnewvalfalse); 
        } 

        private 
    void updateSingleStat(MapleStat statint newvalboolean itemReaction) { 
            
    announce(MaplePacketCreator.updatePlayerStats(Collections.singletonList(new Pair<>(statInteger.valueOf(newval))), itemReaction)); 
        } 

        public 
    void announce(final byte[] packet) { 
            
    client.announce(packet); 
        } 

       [
    MENTION=2000004426]Override[/MENTION
        public 
    int getObjectId() { 
            return 
    getId(); 
        } 

       [
    MENTION=2000004426]Override[/MENTION
        public 
    MapleMapObjectType getType() { 
            return 
    MapleMapObjectType.PLAYER
        } 

       [
    MENTION=2000004426]Override[/MENTION
        public 
    void sendDestroyData(MapleClient client) { 
            
    client.announce(MaplePacketCreator.removePlayerFromMap(this.getObjectId())); 
        } 

       [
    MENTION=2000004426]Override[/MENTION
        public 
    void sendSpawnData(MapleClient client) { 
            if (!
    this.isHidden() || client.getPlayer().gmLevel() > 0) { 
                
    client.announce(MaplePacketCreator.spawnPlayerMapobject(this)); 
            } 
        } 

       [
    MENTION=2000004426]Override[/MENTION
        public 
    void setObjectId(int id) { 
        } 

       [
    MENTION=2000004426]Override[/MENTION
        public 
    String toString() { 
            return 
    name
        } 

        private 
    int givenRiceCakes
        private 
    boolean gottenRiceHat

        public 
    int getGivenRiceCakes() { 
            return 
    givenRiceCakes
        } 

        public 
    void increaseGivenRiceCakes(int amount) { 
            
    this.givenRiceCakes += amount
        } 

        public 
    boolean getGottenRiceHat() { 
            return 
    gottenRiceHat
        } 

        public 
    void setGottenRiceHat(boolean b) { 
            
    this.gottenRiceHat b
        } 

        public 
    int getLinkedLevel() { 
            return 
    linkedLevel
        } 

        public 
    String getLinkedName() { 
            return 
    linkedName
        } 

        public 
    CashShop getCashShop() { 
            return 
    cashshop
        } 

        public 
    void portalDelay(long delay) { 
            
    this.portaldelay System.currentTimeMillis() + delay
        } 

        public 
    long portalDelay() { 
            return 
    portaldelay
        } 

        public 
    void blockPortal(String scriptName) { 
            if (!
    blockedPortals.contains(scriptName) && scriptName != null) { 
                
    blockedPortals.add(scriptName); 
                
    client.announce(MaplePacketCreator.enableActions()); 
            } 
        } 

        public 
    void unblockPortal(String scriptName) { 
            if (
    blockedPortals.contains(scriptName) && scriptName != null) { 
                
    blockedPortals.remove(scriptName); 
            } 
        } 

        public List<
    StringgetBlockedPortals() { 
            return 
    blockedPortals
        } 

        public 
    boolean containsAreaInfo(int areaString info) { 
            
    Short area_ Short.valueOf((shortarea); 
            if (
    area_info.containsKey(area_)) { 
                return 
    area_info.get(area_).contains(info); 
            } 
            return 
    false
        } 

        public 
    void updateAreaInfo(int areaString info) { 
            
    area_info.put(Short.valueOf((shortarea), info); 
            
    announce(MaplePacketCreator.updateAreaInfo(areainfo)); 
        } 

        public 
    String getAreaInfo(int area) { 
            return 
    area_info.get(Short.valueOf((shortarea)); 
        } 

        public 
    Map<ShortStringgetAreaInfos() { 
            return 
    area_info
        } 

        public 
    void autoban(String reasonint greason) { 
            
    Calendar cal Calendar.getInstance(); 
            
    cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE)); 
            
    Timestamp TS = new Timestamp(cal.getTimeInMillis()); 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE accounts SET banreason = ?, tempban = ?, greason = ? WHERE id = ?")) { 
                    
    ps.setString(1reason); 
                    
    ps.setTimestamp(2TS); 
                    
    ps.setInt(3greason); 
                    
    ps.setInt(4accountid); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
            } 
        } 

        public 
    void block(int reasonint daysString desc) { 
            
    Calendar cal Calendar.getInstance(); 
            
    cal.add(Calendar.DATEdays); 
            
    Timestamp TS = new Timestamp(cal.getTimeInMillis()); 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE accounts SET banreason = ?, tempban = ?, greason = ? WHERE id = ?")) { 
                    
    ps.setString(1desc); 
                    
    ps.setTimestamp(2TS); 
                    
    ps.setInt(3reason); 
                    
    ps.setInt(4accountid); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
            } 
        } 

        public 
    boolean isBanned() { 
            return 
    isbanned
        } 

        public 
    int[] getTrockMaps() { 
            return 
    trockmaps
        } 

        public 
    int[] getVipTrockMaps() { 
            return 
    viptrockmaps
        } 

        public 
    int getTrockSize() { 
            
    int ret 0
            for (
    int i 05i++) { 
                if (
    trockmaps[i] != 999999999) { 
                    
    ret++; 
                } 
            } 
            return 
    ret
        } 

        public 
    void deleteFromTrocks(int map) { 
            for (
    int i 05i++) { 
                if (
    trockmaps[i] == map) { 
                    
    trockmaps[i] = 999999999
                    break; 
                } 
            } 
        } 

        public 
    void addTrockMap() { 
            if (
    getTrockSize() >= 5) { 
                return; 
            } 
            
    trockmaps[getTrockSize()] = getMapId(); 
        } 

        public 
    boolean isTrockMap(int id) { 
            for (
    int i 05i++) { 
                if (
    trockmaps[i] == id) { 
                    return 
    true
                } 
            } 
            return 
    false
        } 

        public 
    int getVipTrockSize() { 
            
    int ret 0
            for (
    int i 010i++) { 
                if (
    viptrockmaps[i] != 999999999) { 
                    
    ret++; 
                } 
            } 
            return 
    ret
        } 

        public 
    void deleteFromVipTrocks(int map) { 
            for (
    int i 010i++) { 
                if (
    viptrockmaps[i] == map) { 
                    
    viptrockmaps[i] = 999999999
                    break; 
                } 
            } 
        } 

        public 
    void addVipTrockMap() { 
            if (
    getVipTrockSize() >= 10) { 
                return; 
            } 

            
    viptrockmaps[getVipTrockSize()] = getMapId(); 
        } 

        public 
    boolean isVipTrockMap(int id) { 
            for (
    int i 010i++) { 
                if (
    viptrockmaps[i] == id) { 
                    return 
    true
                } 
            } 
            return 
    false
        } 

        
    // EVENTS 
        
    private byte team 0
        private 
    MapleFitness fitness
        private 
    MapleOla ola
        private 
    long snowballattack

        public 
    byte getTeam() { 
            return 
    team
        } 

        public 
    void setTeam(int team) { 
            
    this.team = (byteteam
        } 

        public 
    MapleOla getOla() { 
            return 
    ola
        } 

        public 
    void setOla(MapleOla ola) { 
            
    this.ola ola
        } 

        public 
    MapleFitness getFitness() { 
            return 
    fitness
        } 

        public 
    void setFitness(MapleFitness fit) { 
            
    this.fitness fit
        } 

        public 
    long getLastSnowballAttack() { 
            return 
    snowballattack
        } 

        public 
    void setLastSnowballAttack(long time) { 
            
    this.snowballattack time
        } 

        
    // Monster Carnival 
        
    private int cp 0
        private 
    int obtainedcp 0
        private 
    MonsterCarnivalParty carnivalparty
        private 
    MonsterCarnival carnival

        public 
    MonsterCarnivalParty getCarnivalParty() { 
            return 
    carnivalparty
        } 

        public 
    void setCarnivalParty(MonsterCarnivalParty party) { 
            
    this.carnivalparty party
        } 

        public 
    MonsterCarnival getCarnival() { 
            return 
    carnival
        } 

        public 
    void setCarnival(MonsterCarnival car) { 
            
    this.carnival car
        } 

        public 
    int getCP() { 
            return 
    cp
        } 

        public 
    int getObtainedCP() { 
            return 
    obtainedcp
        } 

        public 
    void addCP(int cp) { 
            
    this.cp += cp
            
    this.obtainedcp += cp
        } 

        public 
    void useCP(int cp) { 
            
    this.cp -= cp
        } 

        public 
    void setObtainedCP(int cp) { 
            
    this.obtainedcp cp
        } 

        public 
    int getAndRemoveCP() { 
            
    int rCP 10
            if (
    cp 9) { 
                
    rCP cp
                
    cp 0
            } else { 
                
    cp -= 10
            } 

            return 
    rCP
        } 

        public 
    AutobanManager getAutobanManager() { 
            return 
    autoban
        } 

        public 
    void equipPendantOfSpirit() { 
            if (
    pendantOfSpirit == null) { 
                
    pendantOfSpirit TimerManager.getInstance().register(new Runnable() { 
                   [
    MENTION=2000004426]Override[/MENTION
                    public 
    void run() { 
                        if (
    pendantExp 3) { 
                            
    pendantExp++; 
                            
    message("Pendant of the Spirit has been equipped for " pendantExp " hour(s), you will now receive " pendantExp "0% bonus exp."); 
                        } else { 
                            
    pendantOfSpirit.cancel(false); 
                        } 
                    } 
                }, 
    3600000); // 1 hour 
            

        } 

        public 
    void unequipPendantOfSpirit() { 
            if (
    pendantOfSpirit != null) { 
                
    pendantOfSpirit.cancel(false); 
                
    pendantOfSpirit null
            } 
            
    pendantExp 0
        } 

        public 
    void increaseEquipExp(int mobexp) { 
            
    MapleItemInformationProvider mii MapleItemInformationProvider.getInstance(); 
            for (
    Item item getInventory(MapleInventoryType.EQUIPPED).list()) { 
                
    Equip nEquip = (Equipitem
                
    String itemName mii.getName(nEquip.getItemId()); 
                if (
    itemName == null) { 
                    continue; 
                } 

                if ((
    itemName.contains("Reverse") && nEquip.getItemLevel() < 4) || itemName.contains("Timeless") && nEquip.getItemLevel() < 6) { 
                    
    nEquip.gainItemExp(clientmobexpitemName.contains("Timeless")); 
                } 
            } 
        } 

        public 
    Map<StringMapleEventsgetEvents() { 
            return 
    events
        } 

        public 
    PartyQuest getPartyQuest() { 
            return 
    partyQuest
        } 

        public 
    void setPartyQuest(PartyQuest pq) { 
            
    this.partyQuest pq
        } 

        public final 
    void empty(final boolean remove) {// lol serious shit here 
            
    if (dragonBloodSchedule != null) { 
                
    dragonBloodSchedule.cancel(false); 
            } 
            if (
    hpDecreaseTask != null) { 
                
    hpDecreaseTask.cancel(false); 
            } 
            if (
    beholderHealingSchedule != null) { 
                
    beholderHealingSchedule.cancel(false); 
            } 
            if (
    beholderBuffSchedule != null) { 
                
    beholderBuffSchedule.cancel(false); 
            } 
            if (
    BerserkSchedule != null) { 
                
    BerserkSchedule.cancel(false); 
            } 
            if (
    recoveryTask != null) { 
                
    recoveryTask.cancel(false); 
            } 
            
    cancelExpirationTask(); 
            for (
    ScheduledFuture<?> sf : timers) { 
                sf.cancel(false); 
            } 
            timers.clear(); 
            if (maplemount != null) { 
                maplemount.empty(); 
                maplemount = null; 
            } 
            if (remove) { 
                partyQuest = null; 
                events = null; 
                mpc = null; 
                mgc = null; 
                events = null; 
                party = null; 
                family = null; 
                client = null; 
                map = null; 
                timers = null; 
            } 
        } 

        public void logOff() { 
            this.loggedIn = false; 
        } 

        public boolean isLoggedin() { 
            return loggedIn; 
        } 

        public void setMapId(int mapid) { 
            this.mapid = mapid; 
        } 

        public void doReborn(int job) { 
            final int base = 10; 
            this.reborns++; 
            this.job = MapleJob.getById(job); 
            this.exp.set(0); 
            this.level = base; 
            this.setRemainingAp(getRemainingAp() + (base * 5)); 
            List<Pair<MapleStat, Integer>> statups = new ArrayList<>(); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.JOB, this.job.jobid)); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.LEVEL, getLevel())); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.EXP, exp.get())); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, getRemainingAp())); 
            announce(MaplePacketCreator.updatePlayerStats(statups)); 
            dropMessage("You now have a grand total of " + reborns + " reborns."); 

            String hisher = "his"; 
            if (gender == 1) 
                hisher = "her"; 

            String hesheit = "he"; 
            if (gender == 1) 
                hesheit = "she"; 
            // TODO: put milestones into somewhere concise 
            switch (reborns) { 
                case 1: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 1st reborn! Well done!")); 
                    break; 
                case 10: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 10th reborn!")); 
                    break; 
                case 25: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 25th reborn!")); 
                    break; 
                case 50: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 50th reborn!")); 
                    break; 
                case 100: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 100th reborn, truly remarkable!")); 
                    break; 
                case 1000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 1000th reborn, an amazing feat!")); 
                    break; 
                case 5000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on hitting the " + hisher + " 5000th! Just when does it stops?")); 
                    break; 
                case 50000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "The player '" + name + "' has just hit " + hisher + " 50000th reborn. How morbedly obese " + hesheit + " is has yet to be found.")); 
                    break; 
                case 100000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "The player '" + name + " has been found dead lying in a pile of mcdonald Double Quarter Pounder wrappers after having a heart attack. Congratulation on " + hisher + " 100,000th reborn! You may have just won the game.")); 
                    break; 
            } 
        } 

        public long[] getTimestampBuffer() { 
            return timestampBuffer; 
        } 

        public void setTimestamp(int id, long time) { 
            this.timestampBuffer[id] = time; 
        } 

        public long getTimestamp(int id) { 
            return this.timestampBuffer[id]; 
        } 

        // 0,1,2,3 used 
        public boolean matchTimestamp(int duration, int id) { 
            if (id < 0) { 
                throw new InvalidParameterException("Id must be positive!"); 
            } 
            if (duration < 0) { 
                duration = 0; 
            } 

            long elapsed = System.currentTimeMillis() - timestampBuffer[id]; 

            if (elapsed < duration) { 
                return true; 
            } 

            timestampBuffer[id] = System.currentTimeMillis(); 
            return false; 
        } 

        public void setReborn(int reborns) { 
            this.reborns = reborns; 
        } 

        public int getReborns() { 
            return reborns; 
        } 

        public Channel getChannel() { 
            return client.getChannelServer(); 
        } 

        public void addJumpPoints(int i) { 
            this.jumppoints += i; 
        } 

        public void setJumpPoints(int i) { 
            this.jumppoints = i; 
        } 

        public int getJumpPoints() { 
            return jumppoints; 
        } 

        public void fakeRelog() { 
            announce(MaplePacketCreator.getCharInfo(this)); 
            changeMap(map, map.getPortal(map.findClosestSpawnpoint(getPosition()).getId())); 
        } 

        public int getEventPoints() { 
            return eventpoints; 
        } 

        public void setEventPoints(int eventpoints) { 
            this.eventpoints = eventpoints; 
        } 

        public int getVotePoints() { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?"); 
                ps.setInt(1, getAccountID()); 
                ResultSet rs = ps.executeQuery(); 
                rs.next(); 
                int val = rs.getInt("votepoints"); 
                rs.close(); 
                ps.close(); 
                return val; 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            return -1; 
        } 

        public void gainVotePoints(int i) { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET votepoints = ? WHERE id = ?"); 
                ps.setInt(1, getVotePoints() + i); 
                ps.setInt(2, getAccountID()); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        public int getDonorPoints() { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?"); 
                ps.setInt(1, getAccountID()); 
                ResultSet rs = ps.executeQuery(); 
                rs.next(); 
                int val = rs.getInt("donorpoints"); 
                rs.close(); 
                ps.close(); 
                return val; 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            return -1; 
        } 

        public int getTotalDonorPoints() { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?"); 
                ps.setInt(1, getAccountID()); 
                ResultSet rs = ps.executeQuery(); 
                rs.next(); 
                int val = rs.getInt("totaldonorpoints"); 
                rs.close(); 
                ps.close(); 
                return val; 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            return -1; 
        } 

        public void gainDonorPoints(int i) { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET donorpoints = ?, totaldonorpoints = ? WHERE id = ?"); 
                ps.setInt(1, getDonorPoints() + i); 
                ps.setInt(2, getTotalDonorPoints() + i); 
                ps.setInt(3, getAccountID()); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        public void changeChannel(int channel) { 
            Server server = Server.getInstance(); 
            if (isBanned()) { 
                getClient().disconnect(false, false); 
                return; 
            } 
            if (!isAlive() || FieldLimit.CHANGECHANNEL.check(getMap().getFieldLimit())) { 
                getClient().announce(MaplePacketCreator.enableActions()); 
                return; 
            } 
            String[] socket = Server.getInstance().getIP(getClient().getWorld(), channel).split(":"); 
            if (getTrade() != null) { 
                MapleTrade.cancelTrade(getClient().getPlayer()); 
            } 

            HiredMerchant merchant = getHiredMerchant(); 
            if (merchant != null) { 
                if (merchant.isOwner(getClient().getPlayer())) { 
                    merchant.setOpen(true); 
                } else { 
                    merchant.removeVisitor(getClient().getPlayer()); 
                } 
            } 
            server.getPlayerBuffStorage().addBuffsToStorage(getId(), getAllBuffs()); 
            cancelBuffEffects(); 
            cancelMagicDoor(); 
            saveCooldowns(); 

            // Canceling mounts? Noty 
            if (getBuffedValue(MapleBuffStat.PUPPET) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.PUPPET); 
            } 
            if (getBuffedValue(MapleBuffStat.COMBO) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.COMBO); 
            } 
            getInventory(MapleInventoryType.EQUIPPED).checked(false); // test 
            getMap().removePlayer(this); 
            getClient().getChannelServer().removePlayer(this); 
            saveToDB(); 
            getClient().updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION); 
            try { 
                getClient().announce(MaplePacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1]))); 
            } catch (IOException e) { 
            } 
        } 

        /* 
         * 1: perm ban 
         * 2: temp ban 
         * 3: hell ban 
         */ 
        public void ban(int type, String banreason, long tempban) { 
            try { 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ?, tempban = ? WHERE id = ?"); 
                ps.setInt(1, type); 
                ps.setString(2, banreason); 
                if (type == 2) 
                    ps.setDate(3, new Date(tempban)); 
                else 
                    ps.setString(3, "0000-00-00 00:00:00"); 
                ps.setInt(4, getAccountID()); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            sendPolice(banreason, 3200); 
        } 

        /* 
         * 0: perm ban 
         * 1: temp ban 
         * 2: hell ban 
         */ 
        public static void ban(String name, int type, String banreason, long tempban) { 
            try { 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ?, tempban = ? WHERE id = ?"); 
                ps.setInt(1, type); 
                ps.setString(2, banreason); 
                if (type == 1) 
                    ps.setDate(3, new Date(tempban)); 
                else 
                    ps.setString(3, "0000-00-00 00:00:00"); 
                ps.setInt(4, getAccountIdByCharacterName(name)); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        public final Map<CustomQuest, MapleCustomQuestStatus> getCustomQuest_Map() { 
            return customQuests; 
        } 

        public final byte getCustomQuestStatus(final int quest) { 
            final MapleCustomQuestStatus qq = getCustomQuest(CustomQuestProvider.getInstance(quest)); 
            return (qq == null ? 0 : qq.getStatus()); 
        } 

        public final String getCustomQuestData(final int quest) { 
            final MapleCustomQuestStatus qq = getCustomQuest(CustomQuestProvider.getInstance(quest)); 
            if (qq == null) { 
                return ""; 
            } 
            final String info = qq.getCustomData(); 
            return (info == null ? "" : info); 
        } 

        public final MapleCustomQuestStatus getCustomQuest(final CustomQuest quest) { 
            if (quest == null) { 
                return null; 
            } 
            if (!customQuests.containsKey(quest)) { 
                final MapleCustomQuestStatus status = new MapleCustomQuestStatus(quest, (byte) 0); 
                customQuests.put(quest, status); 
                return status; 
            } 
            return customQuests.get(quest); 
        } 

        public final void updateCustomQuest(final MapleCustomQuestStatus quest) { 
            customQuests.put(quest.getQuest(), quest); 
        } 

        public final void setCustomQuestAdd(final CustomQuest quest, final byte status, final String customData) { 
            if (!customQuests.containsKey(quest)) { 
                final MapleCustomQuestStatus stat = new MapleCustomQuestStatus(quest, status); 
                stat.setCustomData(customData); 
                customQuests.put(quest, stat); 
            } 
        } 

        public final void removeCustomQuest(final CustomQuest quest) { 
            if (customQuests.containsKey(quest)) { 
                customQuests.remove(quest); 
            } 
        } 

        public void customMobKilled(final int id, final int skillID) { 
            final StringBuilder sb = new StringBuilder("#bQuest Progress#k\r\n"); 
            for (MapleCustomQuestStatus q : customQuests.values()) { 
                if (q.getStatus() != 1 || !q.hasMobKills()) { 
                    continue; 
                } 
                if (q.mobKilled(id, skillID)) { 
                    sb.append(MapleLifeFactory.getMonster(id).getStats().getName()).append(" #r").append(q.getMobKills(id)).append(" #k/ ").append(q.maxMob(id)).append("\r\n"); 
                    if (q.getQuest().canComplete(this, null)) { 
                        client.getSession().write(MaplePacketCreator.getShowQuestCompletion(1)); // If its 0, then show "New Quest!" 
                    } 
                } 
            } 
            if (sb.indexOf("/") != -1) { 
                client.getSession().write(MaplePacketCreator.sendHint(sb.toString(), 220, 1)); // Ignore height 
            } 
        } 

        public void checkQuestDrops(final int itemId) { 
            final StringBuilder sb = new StringBuilder("#bQuest Progress#k\r\n"); 
            for (MapleCustomQuestStatus q : customQuests.values()) { 
                if (q.getStatus() != 1 || q.getQuest().getReqItems() == null) { 
                    continue; 
                } 
                for (final Entry<Integer, Integer> qa : q.getQuest().getReqItems().entrySet()) { 
                    if (qa.getKey() == itemId) { 
                        if (getItemQuantity(itemId, true) > qa.getValue()) { 
                            continue; 
                        } 
                        sb.append(MapleItemInformationProvider.getInstance().getName(itemId)).append(" #r").append(getItemQuantity(itemId, true)).append(" #k/ ").append(qa.getValue()).append("\r\n"); 
                        if (q.getQuest().canComplete(this, null)) { 
                            client.getSession().write(MaplePacketCreator.getShowQuestCompletion(1)); // If its 0, then show "New Quest!" 
                        } 
                    } 
                } 
            } 
            if (sb.indexOf("/") != -1) { 
                client.getSession().write(MaplePacketCreator.sendHint(sb.toString(), 220, 1)); // Ignore height 
            } 
        } 

        public void talk(String string) { 
            getMap().broadcastMessage(MaplePacketCreator.getChatText(getId(), string, gmLevel() > 3 ? whitechatgm : false, 0)); 
        } 

        public void addTracker(MapleCharacter tracker) { 
            trackers.add(tracker); 
        } 

        public void removeTracker(int cid) { 
            int i = 0; 
            boolean ff = false; 
            for (MapleCharacter track : trackers) { 
                if (track.getId() == cid) { 
                    ff = true; 
                    break; 
                } 
                i++; 
            } 
            if (ff) { 
                trackers.remove(i); 
            } 
        } 

        public List<MapleCharacter> getAllTrackers() { 
            return trackers; 
        } 

        public void notifyTrackers() { 
            for (MapleCharacter track : trackers) { 
                track.dropMessage(5, "Your tracked victim '" + getName() + "' has moved to " + getMap().getMapName() + " in channel " + getClient().getChannel()); 
            } 
        } 

        public void dropItems(int i) { 
            dropItems(i, Randomizer.next(10, 20)); 
        } 

        public void dropItems(int i, int qty) { 
            dropItems(i, qty, 25); 
        } 

        public void dropItems(int i, int qty, int spread) { 
            final int playerpos = getPosition().x; 
            byte d = 1; 
            Point pos = new Point(0, getPosition().y); 

            for (byte b = 0; b < qty; b++) { 
                if (haveItem(i)) { 
                    pos.x = (int) (playerpos + ((d % 2 == 0) ? (spread * (d + 1) / 2) : -(spread * (d / 2)))); 
                    MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(i); 
                    MapleInventoryManipulator.removeById(getClient(), type, i, 1, false, false); 
                    map.spawnItemDrop(this, this, new Item(i, (byte) 0, (short) 1), map.calcDropPos(pos, getPosition()), true, true); 
                    d++; 
                } else { 
                    break; 
                } 
            } 
        } 

        public int tryExecutePower(int id) { 
            return tryExecutePower(id, null, false); 
        } 

        public int tryExecutePower(int id, boolean print) { 
            return tryExecutePower(id, null, print); 
        } 

        public int tryExecutePower(int id, String[] splitted, boolean print) { 
            OccupationFactory factory = OccupationFactory.getInstance(); 
            if (getOccupation() != null) { 
                for (OccupationInfo info : factory.getAllOccupations()) { 
                    if (info.getId() == getOccupation().getInfo().getId()) { 
                        for (Pair<Integer, OccupationPower> power : info.powers) { 
                            if (power.getRight().getId() == id) { 
                                if (power.getLeft() <= getOccupation().getLevel()) { 
                                    return power.getRight().execute(getClient(), splitted != null, splitted); 
                                } else { 
                                    if (print) 
                                        dropMessage(5, "Your occupation level does not match the required level for this power. (required: " + power.getLeft() + ")"); 
                                    return 1; 
                                } 
                            } 
                        } 
                    } 
                } 
            } else { 
                return -3; // No occupation ! 
            } 
            if (print) 
                dropMessage(5, "It seems like you do not have access to this power"); 
            return -1; // power not found! dohhh! 
        } 

        public void gainOccupationExp(int amount) { 
            getOccupation().gainExp(amount); 
        } 

        public OccupationEntry getOccupation() { 
            return occupation; 
        } 

        public void changeOccupation(int id, int level, int exp) { 
            if (id == -1) 
                occupation = null; 
            else { 
                if (id == 0) 
                    pollHeneHoe(true); 
                occupation = OccupationEntry.generateEntry(this, id, level, exp); 
                getMap().broadcastMessage(this, MaplePacketCreator.showForeignEffect(getId(), 8), true); 
            } 
        } 

        public void changeOccupation(int id, int level) { 
            changeOccupation(id, level, 0); 
        } 

        public void undressAll() { 
            List<Item> itemMap = new LinkedList<>(); 
            for (Item item : getInventory(MapleInventoryType.EQUIPPED).list()) { 
                itemMap.add((Item) item); 
            } 
            for (Item item : itemMap) { 
                if (!getInventory(MapleInventoryType.EQUIP).isFull()) { 
                    MapleInventoryManipulator.unequip(getClient(), item.getPosition(), getInventory(MapleInventoryType.EQUIP).getNextFreeSlot()); 
                } 
            } 
        } 

        public void die() { 
            setHp(0); 
            updateSingleStat(MapleStat.HP, 0); 
        } 

        public void gainOccuExp(int j) { 
            int i = j - 2; 
            if (i < 1) 
                i = 1; 
            MapleInventoryManipulator.addById(client, 4032061, (short) Randomizer.next(i, j)); 
            occupation.gainExp(j); 
        } 

        public void pollHeneHoe(boolean initialize) { 
            if (getMapId() == 100000000 || getMapId() == 910000000) { // still in henesys ? 
                if (!initialize) { 
                    int delta = Randomizer.next(2, 5); 
                    gainOccuExp(delta); 
                    dropMessage(-1, "You have gained " + delta + " occupation EXP for staying in henesys !"); 
                } 
                TimerManager.getInstance().schedule(new Runnable() { 
                    public void run() { 
                        pollHeneHoe(false); 
                    } 
                }, 1000 * 60 * Randomizer.next(2, 4)); 
            } 
            TimerManager.getInstance().purge(); 
        } 

    }
    - - - Updated - - -

    Quote Originally Posted by AngelSpirit View Post

    Just....just post the MapleCharacter class so we can end this.
    Thank you (:

    Spoiler:
    PHP Code:
    /*  
     This file is part of the OdinMS Maple Story Server 
     Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
     Matthias Butz <matze@odinms.de> 
     Jan Christian Meyer <vimes@odinms.de> 

     This program is free software: you can redistribute it and/or modify 
     it under the terms of the GNU Affero General Public License as 
     published by the Free Software Foundation version 3 as published by 
     the Free Software Foundation. You may not use, modify or distribute 
     this program unader any cother version of the GNU Affero General Public 
     License. 

     This program is distributed in the hope that it will be useful, 
     but WITHOUT ANY WARRANTY; without even the implied warranty of 
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     GNU Affero General Public License for more details. 

     You should have received a copy of the GNU Affero General Public License 
     along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     */ 
    package client; 

    import java.awt.Point; 
    import java.io.IOException; 
    import java.lang.ref.WeakReference; 
    import java.net.InetAddress; 
    import java.security.InvalidParameterException; 
    import java.sql.Connection; 
    import java.sql.Date; 
    import java.sql.PreparedStatement; 
    import java.sql.ResultSet; 
    import java.sql.SQLException; 
    import java.sql.Statement; 
    import java.sql.Timestamp; 
    import java.text.DecimalFormat; 
    import java.text.NumberFormat; 
    import java.util.ArrayList; 
    import java.util.Arrays; 
    import java.util.Calendar; 
    import java.util.Collection; 
    import java.util.Collections; 
    import java.util.EnumMap; 
    import java.util.Iterator; 
    import java.util.LinkedHashMap; 
    import java.util.LinkedHashSet; 
    import java.util.LinkedList; 
    import java.util.List; 
    import java.util.Map; 
    import java.util.Map.Entry; 
    import java.util.Set; 
    import java.util.concurrent.ScheduledFuture; 
    import java.util.concurrent.atomic.AtomicInteger; 
    import java.util.regex.Pattern; 

    import net.server.PlayerBuffValueHolder; 
    import net.server.PlayerCoolDownValueHolder; 
    import net.server.PlayerDiseaseValueHolder; 
    import net.server.Server; 
    import net.server.channel.Channel; 
    import net.server.guild.MapleGuild; 
    import net.server.guild.MapleGuildCharacter; 
    import net.server.world.MapleMessenger; 
    import net.server.world.MapleMessengerCharacter; 
    import net.server.world.MapleParty; 
    import net.server.world.MaplePartyCharacter; 
    import net.server.world.PartyOperation; 
    import net.server.world.World; 
    import scripting.event.EventInstanceManager; 
    import server.CashShop; 
    import server.MapleInventoryManipulator; 
    import server.MapleItemInformationProvider; 
    import server.MaplePlayerShop; 
    import server.MaplePortal; 
    import server.MapleShop; 
    import server.MapleStatEffect; 
    import server.MapleStorage; 
    import server.MapleTrade; 
    import server.TimerManager; 
    import server.events.MapleEvents; 
    import server.events.RescueGaga; 
    import server.events.gm.MapleFitness; 
    import server.events.gm.MapleOla; 
    import server.life.MapleLifeFactory; 
    import server.life.MapleMonster; 
    import server.life.MobSkill; 
    import server.maps.AbstractAnimatedMapleMapObject; 
    import server.maps.FieldLimit; 
    import server.maps.HiredMerchant; 
    import server.maps.MapleDoor; 
    import server.maps.MapleMap; 
    import server.maps.MapleMapEffect; 
    import server.maps.MapleMapFactory; 
    import server.maps.MapleMapObject; 
    import server.maps.MapleMapObjectType; 
    import server.maps.MapleSummon; 
    import server.maps.PlayerNPCs; 
    import server.maps.SavedLocation; 
    import server.maps.SavedLocationType; 
    import server.minigames.AbstractMinigame; 
    import server.minigames.IMinigame; 
    import server.partyquest.MonsterCarnival; 
    import server.partyquest.MonsterCarnivalParty; 
    import server.partyquest.PartyQuest; 
    import server.quest.MapleQuest; 
    import server.quest.custom.CustomQuest; 
    import server.quest.custom.CustomQuestProvider; 
    import tools.DatabaseConnection; 
    import tools.FilePrinter; 
    import tools.MaplePacketCreator; 
    import tools.Pair; 
    import tools.Randomizer; 
    import client.autoban.AutobanManager; 
    import client.inventory.Equip; 
    import client.inventory.Item; 
    import client.inventory.ItemFactory; 
    import client.inventory.MapleInventory; 
    import client.inventory.MapleInventoryType; 
    import client.inventory.MaplePet; 
    import client.inventory.MapleWeaponType; 
    import client.inventory.ModifyInventory; 
    import client.occupations.OccupationEntry; 
    import client.occupations.OccupationFactory; 
    import client.occupations.OccupationInfo; 
    import client.occupations.powers.OccupationPower; 
    import constants.ExpTable; 
    import constants.ItemConstants; 
    import constants.ServerConstants; 
    import constants.skills.Bishop; 
    import constants.skills.BlazeWizard; 
    import constants.skills.Corsair; 
    import constants.skills.Crusader; 
    import constants.skills.DarkKnight; 
    import constants.skills.DawnWarrior; 
    import constants.skills.FPArchMage; 
    import constants.skills.GM; 
    import constants.skills.Hermit; 
    import constants.skills.ILArchMage; 
    import constants.skills.Magician; 
    import constants.skills.Marauder; 
    import constants.skills.Priest; 
    import constants.skills.Ranger; 
    import constants.skills.Sniper; 
    import constants.skills.Spearman; 
    import constants.skills.SuperGM; 
    import constants.skills.Swordsman; 
    import constants.skills.ThunderBreaker; 

    public class MapleCharacter extends AbstractAnimatedMapleMapObject { 

        private static final String LEVEL_200 = "[Congrats] %s has reached Level 200! Congratulate %s on such an amazing achievement!"; 
        private static final int[] DEFAULT_KEY = { 18, 65, 2, 23, 3, 4, 5, 6, 16, 17, 19, 25, 26, 27, 31, 34, 35, 37, 38, 
            40, 43, 44, 45, 46, 50, 56, 59, 60, 61, 62, 63, 64, 57, 48, 29, 7, 24, 33, 41, 39 }; 
        private static final int[] DEFAULT_TYPE = { 4, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 
            4, 5, 6, 6, 6, 6, 6, 6, 5, 4, 5, 4, 4, 4, 4, 4 }; 
        private static final int[] DEFAULT_ACTION = { 0, 106, 10, 1, 12, 13, 18, 24, 8, 5, 4, 19, 14, 15, 2, 17, 11, 3, 20, 
            16, 9, 50, 51, 6, 7, 53, 100, 101, 102, 103, 104, 105, 54, 22, 52, 21, 25, 26, 23, 27 }; 
        private int world; 
        private int accountid, id; 
        private int rank, rankMove, jobRank, jobRankMove; 
        private int level, str, dex, luk, int_, hp, maxhp, mp, maxmp; 
        private int hpMpApUsed; 
        private int hair; 
        private int face; 
        private int remainingAp, remainingSp; 
        private int fame; 
        private int initialSpawnPoint; 
        private int mapid; 
        private int gender; 
        private int currentPage, currentType = 0, currentTab = 1; 
        private int chair; 
        private int itemEffect; 
        private int guildid, guildrank, allianceRank; 
        private int messengerposition = 4; 
        private int slots = 0; 
        private int energybar; 
        private int gmLevel; 
        private int ci = 0; 
        private MapleFamily family; 
        private int familyId; 
        private int bookCover; 
        private int markedMonster = 0; 
        private int battleshipHp = 0; 
        private int mesosTraded = 0; 
        private int possibleReports = 10; 
        private int dojoPoints, vanquisherStage, dojoStage, dojoEnergy, vanquisherKills; 
        private int warpToId; 
        private int expRate = 1, mesoRate = 1, dropRate = 1; 
        private int omokwins, omokties, omoklosses, matchcardwins, matchcardties, matchcardlosses; 
        private int married; 
        private long dojoFinish, lastfametime, lastUsedCashItem, lastHealed; 
        private transient int localmaxhp, localmaxmp, localstr, localdex, localluk, localint_, magic, watk; 
        private boolean hidden, canDoor = true, Berserk, hasMerchant; 
        private int linkedLevel = 0; 
        private String linkedName = null; 
        private boolean finishedDojoTutorial, dojoParty; 
        private String name; 
        private String chalktext; 
        private String search = null; 
        private AtomicInteger exp = new AtomicInteger(); 
        private AtomicInteger gachaexp = new AtomicInteger(); 
        private AtomicInteger meso = new AtomicInteger(); 
        private int merchantmeso; 
        private BuddyList buddylist; 
        private EventInstanceManager eventInstance = null; 
        private HiredMerchant hiredMerchant = null; 
        private MapleClient client; 
        private MapleGuildCharacter mgc = null; 
        private MaplePartyCharacter mpc = null; 
        private MapleInventory[] inventory; 
        private MapleJob job = MapleJob.BEGINNER; 
        private MapleMap map, dojoMap;// Make a Dojo pq instance 
        private MapleMessenger messenger = null; 
        private AbstractMinigame miniGame; 
        private MapleMount maplemount; 
        private MapleParty party; 
        private MaplePet[] pets = new MaplePet[3]; 
        private MaplePlayerShop playerShop = null; 
        private MapleShop shop = null; 
        private MapleSkinColor skinColor = MapleSkinColor.NORMAL; 
        private MapleStorage storage = null; 
        private MapleTrade trade = null; 
        private SavedLocation savedLocations[]; 
        private SkillMacro[] skillMacros = new SkillMacro[5]; 
        private List<Integer> lastmonthfameids; 
        private Map<MapleQuest, MapleQuestStatus> quests; 
        private Set<MapleMonster> controlled = new LinkedHashSet<>(); 
        private Map<Integer, String> entered = new LinkedHashMap<>(); 
        private Set<MapleMapObject> visibleMapObjects = new LinkedHashSet<>(); 
        private Map<Skill, SkillEntry> skills = new LinkedHashMap<>(); 
        private EnumMap<MapleBuffStat, MapleBuffStatValueHolder> effects = new EnumMap<>(MapleBuffStat.class); 
        private Map<Integer, MapleKeyBinding> keymap = new LinkedHashMap<>(); 
        private Map<Integer, MapleSummon> summons = new LinkedHashMap<>(); 
        private Map<Integer, MapleCoolDownValueHolder> coolDowns = new LinkedHashMap<>(50); 
        private EnumMap<MapleDisease, DiseaseValueHolder> diseases = new EnumMap<>(MapleDisease.class); 
        private List<MapleDoor> doors = new ArrayList<>(); 
        private ScheduledFuture<?dragonBloodSchedule
        private 
    ScheduledFuture<?> mapTimeLimitTask = null; 
        private ScheduledFuture<?>[] fullnessSchedule = new ScheduledFuture<?>[3]; 
        private ScheduledFuture<?hpDecreaseTask
        private 
    ScheduledFuture<?> beholderHealingSchedule, beholderBuffSchedule, BerserkSchedule; 
        private ScheduledFuture<?expiretask
        private 
    ScheduledFuture<?> recoveryTask; 
        private List<ScheduledFuture<?>> timers = new ArrayList<>(); 
        private 
    NumberFormat nf = new DecimalFormat("#,###,###,###"); 
        private 
    ArrayList<Integerexcluded = new ArrayList<>(); 
        private 
    MonsterBook monsterbook
        private List<
    MapleRingcrushRings = new ArrayList<>(); 
        private List<
    MapleRingfriendshipRings = new ArrayList<>(); 
        private 
    MapleRing marriageRing
        private static 
    String[] ariantroomleader = new String[3]; 
        private static 
    int[] ariantroomslot = new int[3]; 
        private 
    CashShop cashshop
        private 
    long portaldelay 0lastcombo 0
        private 
    short combocounter 0
        private List<
    StringblockedPortals = new ArrayList<>(); 
        private 
    Map<ShortStringarea_info = new LinkedHashMap<>(); 
        private 
    AutobanManager autoban
        private 
    boolean isbanned false
        private 
    ScheduledFuture<?> pendantOfSpirit = null; // 1122017 
        private byte pendantExp = 0, lastmobcount = 0; 
        private int[] trockmaps = new int[5]; 
        private int[] viptrockmaps = new int[10]; 
        private Map<String, MapleEvents> events = new LinkedHashMap<>(); 
        private PartyQuest partyQuest = null; 
        private boolean loggedIn = false; 
        // custom shit begins here 
            private int legend; 
            private int horntail_slyed, pinkbeen_slyed; 
            private int expbonuses; 
        private long[] timestampBuffer = new long[256]; 
        public long jailduration, jailtime; 
        public boolean jailed; 
        public boolean autoreborn; 
        private int reborns, jumppoints, eventpoints; 
        public long tempmutetime, tempmuteduration; 
        public boolean muted, tempmuted, whitechatgm; 
        private Map<CustomQuest, MapleCustomQuestStatus> customQuests; 
        private List<MapleCharacter> trackers = new ArrayList<>(); 
        private MapleCharacter watcher = null; 
        public OccupationEntry occupation; 

        private MapleCharacter() { 
            setStance(0); 
            inventory = new MapleInventory[MapleInventoryType.values().length]; 
            savedLocations = new SavedLocation[SavedLocationType.values().length]; 

            for (MapleInventoryType type : MapleInventoryType.values()) { 
                byte b = 24; 
                if (type == MapleInventoryType.CASH) { 
                    b = 96; 
                } 
                inventory[type.ordinal()] = new MapleInventory(type, (byte) b); 
            } 
            for (int i = 0; i < SavedLocationType.values().length; i++) { 
                savedLocations[i] = null; 
            } 
            quests = new LinkedHashMap<>(); 
            customQuests = new LinkedHashMap<>(); 
            setPosition(new Point(0, 0)); 
        } 

        public static MapleCharacter getDefault(MapleClient c) { 
            MapleCharacter ret = new MapleCharacter(); 
            ret.client = c; 
            ret.gmLevel = c.gmLevel(); 
            ret.hp = 50; 
            ret.maxhp = 50; 
            ret.mp = 5; 
                    ret.expbonuses=0; 
            ret.maxmp = 5; 
            ret.str = 12; 
            ret.dex = 5; 
            ret.int_ = 4; 
            ret.luk = 4; 
            ret.map = null; 
            ret.job = MapleJob.BEGINNER; 
            ret.level = 1; 
            ret.accountid = c.getAccID(); 
            ret.buddylist = new BuddyList(20); 
            ret.maplemount = null; 
                    ret.legend = 0; 
                    ret.pinkbeen_slyed = 0; 
                    ret.horntail_slyed = 0; 
            ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(96); 
            ret.getInventory(MapleInventoryType.USE).setSlotLimit(96); 
            ret.getInventory(MapleInventoryType.SETUP).setSlotLimit(96); 
            ret.getInventory(MapleInventoryType.ETC).setSlotLimit(96); 
            for (int i = 0; i < DEFAULT_KEY.length; i++) { 
                ret.keymap.put(DEFAULT_KEY[i], new MapleKeyBinding(DEFAULT_TYPE[i], DEFAULT_ACTION[i])); 
            } 
            // to fix the map 0 lol 
            for (int i = 0; i < 5; i++) { 
                ret.trockmaps[i] = 999999999; 
            } 
            for (int i = 0; i < 10; i++) { 
                ret.viptrockmaps[i] = 999999999; 
            } 

            if (ret.isGM()) { 
                ret.job = MapleJob.SUPERGM; 
                ret.level = 200; 
                // int[] gmskills = {9001000, 9001001, 9001000, 9101000, 9101001, 9101002, 9101003, 9101004, 9101005, 9101006, 9101007, 9101008}; 
            } 
            return ret; 
        } 

        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(skillIdstartTimelengthtimer)); 
        } 

        public 
    void addCrushRing(MapleRing r) { 
            
    crushRings.add(r); 
        } 

        public 
    MapleRing getRingById(int id) { 
            for (
    MapleRing ring getCrushRings()) { 
                if (
    ring.getRingId() == id) { 
                    return 
    ring
                } 
            } 
            for (
    MapleRing ring getFriendshipRings()) { 
                if (
    ring.getRingId() == id) { 
                    return 
    ring
                } 
            } 
            if (
    getMarriageRing().getRingId() == id) { 
                return 
    getMarriageRing(); 
            } 

            return 
    null
        } 

        public 
    int addDojoPointsByMap() { 
            
    int pts 0
            if (
    dojoPoints 17000) { 
                
    pts + ((getMap().getId() - 1) / 100 100) / 6
                if (!
    dojoParty) { 
                    
    pts++; 
                } 
                
    this.dojoPoints += pts
            } 
            return 
    pts
        } 

        public 
    void addDoor(MapleDoor door) { 
            
    doors.add(door); 
        } 

        public 
    void addExcluded(int x) { 
            
    excluded.add(x); 
        } 

        public 
    void addFame(int famechange) { 
            
    this.fame += famechange
        } 

        public 
    void addFriendshipRing(MapleRing r) { 
            
    friendshipRings.add(r); 
        } 

        public 
    void addHP(int delta) { 
            
    setHp(hp delta); 
            
    updateSingleStat(MapleStat.HPhp); 
        } 

        public 
    void addMesosTraded(int gain) { 
            
    this.mesosTraded += gain
        } 

        public 
    void addMP(int delta) { 
            
    setMp(mp delta); 
            
    updateSingleStat(MapleStat.MPmp); 
        } 

        public 
    void addMPHP(int hpDiffint mpDiff) { 
            
    setHp(hp hpDiff); 
            
    setMp(mp mpDiff); 
            
    updateSingleStat(MapleStat.HPgetHp()); 
            
    updateSingleStat(MapleStat.MPgetMp()); 
        } 

        public 
    void addPet(MaplePet pet) { 
            for (
    int i 03i++) { 
                if (
    pets[i] == null) { 
                    
    pets[i] = pet
                    return; 
                } 
            } 
        } 

        public 
    void addStat(int typeint up) { 
            if (
    type == 1) { 
                
    this.str += up
                
    updateSingleStat(MapleStat.STRstr); 
            } else if (
    type == 2) { 
                
    this.dex += up
                
    updateSingleStat(MapleStat.DEXdex); 
            } else if (
    type == 3) { 
                
    this.int_ += up
                
    updateSingleStat(MapleStat.INTint_); 
            } else if (
    type == 4) { 
                
    this.luk += up
                
    updateSingleStat(MapleStat.LUKluk); 
            } 
        } 

        public 
    int addHP(MapleClient c) { 
            
    MapleCharacter player c.getPlayer(); 
            
    MapleJob jobtype player.getJob(); 
            
    int MaxHP player.getMaxHp(); 
            if (
    player.getHpMpApUsed() > 9999 || MaxHP >= 30000) { 
                return 
    MaxHP
            } 
            if (
    jobtype.isA(MapleJob.BEGINNER)) { 
                
    MaxHP += 8
            } else if (
    jobtype.isA(MapleJob.WARRIOR) || jobtype.isA(MapleJob.DAWNWARRIOR1)) { 
                if (
    player.getSkillLevel(player.isCygnus() ? SkillFactory.getSkill(10000000) : SkillFactory.getSkill(1000001)) > 0) { 
                    
    MaxHP += 20
                } else { 
                    
    MaxHP += 8
                } 
            } else if (
    jobtype.isA(MapleJob.MAGICIAN) || jobtype.isA(MapleJob.BLAZEWIZARD1)) { 
                
    MaxHP += 6
            } else if (
    jobtype.isA(MapleJob.BOWMAN) || jobtype.isA(MapleJob.WINDARCHER1)) { 
                
    MaxHP += 8
            } else if (
    jobtype.isA(MapleJob.THIEF) || jobtype.isA(MapleJob.NIGHTWALKER1)) { 
                
    MaxHP += 8
            } else if (
    jobtype.isA(MapleJob.PIRATE) || jobtype.isA(MapleJob.THUNDERBREAKER1)) { 
                if (
    player.getSkillLevel(player.isCygnus() ? SkillFactory.getSkill(15100000) : SkillFactory.getSkill(5100000)) > 0) { 
                    
    MaxHP += 18
                } else { 
                    
    MaxHP += 8
                } 
            } 
            return 
    MaxHP
        } 

        public 
    int addMP(MapleClient c) { 
            
    MapleCharacter player c.getPlayer(); 
            
    int MaxMP player.getMaxMp(); 
            if (
    player.getHpMpApUsed() > 9999 || player.getMaxMp() >= 30000) { 
                return 
    MaxMP
            } 
            if (
    player.getJob().isA(MapleJob.BEGINNER) || player.getJob().isA(MapleJob.NOBLESSE) || player.getJob().isA(MapleJob.LEGEND)) { 
                
    MaxMP += 6
            } else if (
    player.getJob().isA(MapleJob.WARRIOR) || player.getJob().isA(MapleJob.DAWNWARRIOR1) || player.getJob().isA(MapleJob.ARAN1)) { 
                
    MaxMP += 2
            } else if (
    player.getJob().isA(MapleJob.MAGICIAN) || player.getJob().isA(MapleJob.BLAZEWIZARD1)) { 
                if (
    player.getSkillLevel(player.isCygnus() ? SkillFactory.getSkill(12000000) : SkillFactory.getSkill(2000001)) > 0) { 
                    
    MaxMP += 18
                } else { 
                    
    MaxMP += 14
                } 

            } else if (
    player.getJob().isA(MapleJob.BOWMAN) || player.getJob().isA(MapleJob.THIEF)) { 
                
    MaxMP += 10
            } else if (
    player.getJob().isA(MapleJob.PIRATE)) { 
                
    MaxMP += 14
            } 

            return 
    MaxMP
        } 

        public 
    void addSummon(int idMapleSummon summon) { 
            
    summons.put(idsummon); 
        } 

        public 
    void addVisibleMapObject(MapleMapObject mo) { 
            
    visibleMapObjects.add(mo); 
        } 

        public 
    void ban(String reason) { 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) { 
                    
    ps.setString(1reason); 
                    
    ps.setInt(2accountid); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    Exception e) { 
            } 

        } 

        public static 
    boolean ban(String idString reasonboolean accountId) { 
            
    PreparedStatement ps null
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                if (
    id.matches("/[0-9]{1,3}\\..*")) { 
                    
    ps con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)"); 
                    
    ps.setString(1id); 
                    
    ps.executeUpdate(); 
                    
    ps.close(); 
                    return 
    true
                } 
                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(1id); 
                try (
    ResultSet rs ps.executeQuery()) { 
                    if (
    rs.next()) { 
                        try (
    PreparedStatement psb DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?")) { 
                            
    psb.setString(1reason); 
                            
    psb.setInt(2rs.getInt(1)); 
                            
    psb.executeUpdate(); 
                        } 
                        
    ret true
                    } 
                } 
                
    ps.close(); 
                return 
    ret
            } catch (
    SQLException ex) { 
            } finally { 
                try { 
                    if (
    ps != null && !ps.isClosed()) { 
                        
    ps.close(); 
                    } 
                } catch (
    SQLException e) { 
                } 
            } 
            return 
    false
        } 

        public 
    int calculateMaxBaseDamage(int watk) { 
            
    int maxbasedamage
            if (
    watk == 0) { 
                
    maxbasedamage 1
            } else { 
                
    Item 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) || getJob().isA(MapleJob.NIGHTWALKER1)) && (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) + 10
                } else { 
                    
    maxbasedamage 0
                } 
            } 
            return 
    maxbasedamage
        } 

        public 
    void cancelAllBuffs(boolean disconnect) { 
            if (
    disconnect) { 
                
    effects.clear(); 
            } else { 
                for (
    MapleBuffStatValueHolder mbsvh : new ArrayList<>(effects.values())) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        public 
    void cancelBuffStats(MapleBuffStat stat) { 
            List<
    MapleBuffStatbuffStatList Arrays.asList(stat); 
            
    deregisterBuffStats(buffStatList); 
            
    cancelPlayerBuffs(buffStatList); 
        } 

        public 
    void setCombo(short count) { 
            if (
    count combocounter) { 
                
    cancelEffectFromBuffStat(MapleBuffStat.ARAN_COMBO); 
            } 
            
    combocounter = (shortMath.min(30000count); 
            if (
    count 0) { 
                
    announce(MaplePacketCreator.showCombo(combocounter)); 
            } 
        } 

        public 
    void setLastCombo(long time) { 
            ; 
            
    lastcombo time
        } 

        public 
    short getCombo() { 
            return 
    combocounter
        } 

        public 
    long getLastCombo() { 
            return 
    lastcombo
        } 

        public 
    int getLastMobCount() { // Used for skills that have mobCount at 1. (a/b) 
            
    return lastmobcount
        } 

        public 
    void setLastMobCount(byte count) { 
            
    lastmobcount count
        } 

        public 
    void newClient(MapleClient c) { 
            
    this.loggedIn true
            
    c.setAccountName(this.client.getAccountName());// No null's for accountName 
            
    this.client c
            
    MaplePortal portal map.findClosestSpawnpoint(getPosition()); 
            if (
    portal == null) { 
                
    portal map.getPortal(0); 
            } 
            
    this.setPosition(portal.getPosition()); 
            
    this.initialSpawnPoint portal.getId(); 
            
    this.map c.getChannelServer().getMapFactory().getMap(getMapId()); 
        } 

        public 
    void cancelBuffEffects() { 
            for (
    MapleBuffStatValueHolder mbsvh effects.values()) { 
                if (
    mbsvh.schedule != null
                    
    mbsvh.schedule.cancel(false); 
            } 
            
    this.effects.clear(); 
        } 

        public 
    String getMedalText() { 
            
    String medal ""
            final 
    Item medalItem getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -49); 
            if (
    medalItem != null) { 
                
    medal "<" MapleItemInformationProvider.getInstance().getName(medalItem.getItemId()) + "> "
            } 
            return 
    medal
        } 
             
            public 
    void giftMedal(int id) { 
            if (!
    this.getInventory(MapleInventoryType.EQUIP).isFull() && ServerConstants.gain_medals == true && this.getInventory(MapleInventoryType.EQUIP).countById(id) == && this.getInventory(MapleInventoryType.EQUIPPED).countById(id) == 0) { 
             
    MapleInventoryManipulator.addById(clientid,(short1); 
             
    client.announce(MaplePacketCreator.earnTitleMessage("#eYou have just gained an #b" MapleItemInformationProvider.getInstance().getName(id) + "#k! Congrats!")); 
             
    dropMessage("You have just gained an " MapleItemInformationProvider.getInstance().getName(id) + "! Congrats!"); 
            } else if (
    ServerConstants.gain_medals == true && this.getInventory(MapleInventoryType.EQUIP).countById(id) == && this.getInventory(MapleInventoryType.EQUIPPED).countById(id) == 0) { 
             
    MapleInventoryManipulator.drop(clientMapleInventoryType.EQUIP,(byte1, (byte1); 
             
    MapleInventoryManipulator.addById(clientid,(short1); 
             
    client.announce(MaplePacketCreator.earnTitleMessage("#eYou have just gained an #b" MapleItemInformationProvider.getInstance().getName(id) + "#k! Congrats!")); 
             
    dropMessage("You have just gained an " MapleItemInformationProvider.getInstance().getName(id) + "! Congrats!"); 
            } 
        } 
             
            public 
    void setExpBonuses(int amt) { 
        
    this.expbonuses=amt
        } 

        public 
    void addExpBonus() { 
            
    setExpBonuses(this.expbonuses+1); 
            
    dropMessage(ServerConstants.exp_bonus_message); 
            
    client.announce(MaplePacketCreator.earnTitleMessage(ServerConstants.exp_bonus_overhead_message)); 
        } 

        public 
    int getExpBonuses() { 
            return 
    expbonuses
        } 

        public 
    int getHorntailSlyed() { 
            return 
    horntail_slyed
        } 

        public 
    int getPinkBeenSlyed() { 
            return 
    pinkbeen_slyed
        } 

        public 
    void setHorntailSlyed(int set) { 
            
    this.horntail_slyed set
        } 

        public 
    void setPinkBeenSlyed(int set) { 
            
    this.pinkbeen_slyed set
        } 

        public 
    void gainHorntailSlyed(int gain) { 
            
    setHorntailSlyed(getHorntailSlyed() + gain); 
        } 

        public 
    void gainPinkBeenSlyed(int gain) { 
            
    setPinkBeenSlyed(getPinkBeenSlyed() + gain); 
        } 

        public 
    int getLegendById() { 
            return 
    legend
        } 
        public 
    String Legend() { 
            if (
    legend == 1) { 
                return 
    "GameMaster"
            } else if (
    legend == 2) { 
                return 
    "Beginner"
            } else if (
    legend == 3) { 
                return 
    "PartyQuestsMania"
            } else if (
    legend == 4) { 
                return 
    "QuestSpecialists"
            } else if (
    legend == 5) { 
                return 
    "SuperHunter"
            } else if (
    legend == 6) { 
                return 
    "King"
            } else if (
    legend == 7) { 
                return 
    "Devil"
            } else if (
    legend == 8) { 
                return 
    "Genius"
            } else if (
    legend == 9) { 
                return 
    "Ninja"
            } else if (
    legend == 10) { 
                return 
    "Sea King"
            } else if (
    legend == 11) { 
                return 
    "Fame Star"
            } else if (
    legend == 12) { 
                return 
    "Maple Idle Star"
            } else if (
    legend == 13) { 
                return 
    "Horntail Slayer"
            } else if (
    legend == 14) { 
                return 
    "Pinkbeen Slayer"
            } else if (
    legend == 15) { 
                return 
    "Rebirth Power man"
            } else if (
    legend == 16) { 
                return 
    "Loss King"
            } else if (
    legend == 17) { 
                return 
    "Win King"
            } else if (
    legend == 18) { 
                return 
    "Romeo"
            } else if (
    legend == 19) { 
                return 
    "Juliet"
            } else if (
    legend == 20) { 
                return 
    "VIPPER"
            } else if (
    legend == 21) { 
                return 
    "Rebirth King"
            } else { 
                return 
    null
            } 
        } 

        public 
    String getLegend() { 
            if (
    legend != 0) { 
                return 
    "<" Legend() + "> "
            } else { 
                return 
    ""
            } 
        } 

        public 
    void setlegend(int legendid) { 
            
    this.legend legendid
        } 

        public static class 
    CancelCooldownAction implements Runnable 

            private 
    int skillId
            private 
    WeakReference<MapleCharactertarget

            public 
    CancelCooldownAction(MapleCharacter targetint skillId) { 
                
    this.target = new WeakReference<>(target); 
                
    this.skillId skillId
            } 

          [
    MENTION=2000004426]Override[/MENTION
            public 
    void run() { 
                
    MapleCharacter realTarget target.get(); 
                if (
    realTarget != null) { 
                    
    realTarget.removeCooldown(skillId); 
                    
    realTarget.client.announce(MaplePacketCreator.skillCooldown(skillId0)); 
                } 
            } 
        } 

        public 
    void cancelEffect(int itemId) { 
            
    cancelEffect(MapleItemInformationProvider.getInstance().getItemEffect(itemId), false, -1); 
        } 

        public 
    void cancelEffect(MapleStatEffect effectboolean overwritelong startTime) { 
            List<
    MapleBuffStatbuffstats
            if (!
    overwrite) { 
                
    buffstats getBuffStats(effectstartTime); 
            } else { 
                List<
    Pair<MapleBuffStatInteger>> statups effect.getStatups(); 
                
    buffstats = new ArrayList<>(statups.size()); 
                for (
    Pair<MapleBuffStatIntegerstatup statups) { 
                    
    buffstats.add(statup.getLeft()); 
                } 
            } 
            
    deregisterBuffStats(buffstats); 
            if (
    effect.isMagicDoor()) { 
                if (!
    getDoors().isEmpty()) { 
                    
    MapleDoor door getDoors().iterator().next(); 
                    for (
    MapleCharacter chr door.getTarget().getCharacters()) { 
                        
    door.sendDestroyData(chr.client); 
                    } 
                    for (
    MapleCharacter chr door.getTown().getCharacters()) { 
                        
    door.sendDestroyData(chr.client); 
                    } 
                    for (
    MapleDoor destroyDoor getDoors()) { 
                        
    door.getTarget().removeMapObject(destroyDoor); 
                        
    door.getTown().removeMapObject(destroyDoor); 
                    } 
                    
    clearDoors(); 
                    
    silentPartyUpdate(); 
                } 
            } 
            if (
    effect.getSourceId() == Spearman.HYPER_BODY || effect.getSourceId() == GM.HYPER_BODY || effect.getSourceId() == SuperGM.HYPER_BODY) { 
                List<
    Pair<MapleStatInteger>> statup = new ArrayList<>(4); 
                
    statup.add(new Pair<>(MapleStat.HPMath.min(hpmaxhp))); 
                
    statup.add(new Pair<>(MapleStat.MPMath.min(mpmaxmp))); 
                
    statup.add(new Pair<>(MapleStat.MAXHPmaxhp)); 
                
    statup.add(new Pair<>(MapleStat.MAXMPmaxmp)); 
                
    client.announce(MaplePacketCreator.updatePlayerStats(statup)); 
            } 
            if (
    effect.isMonsterRiding()) { 
                if (
    effect.getSourceId() != Corsair.BATTLE_SHIP) { 
                    
    this.getMount().cancelSchedule(); 
                    
    this.getMount().setActive(false); 
                } 
            } 
            if (!
    overwrite) { 
                
    cancelPlayerBuffs(buffstats); 
            } 
        } 

        public 
    void cancelEffectFromBuffStat(MapleBuffStat stat) { 
            
    MapleBuffStatValueHolder effect effects.get(stat); 
            if (
    effect != null) { 
                
    cancelEffect(effect.effectfalse, -1); 
            } 
        } 

        public 
    void Hide(boolean hideboolean login) { 
            if (
    isGM() && hide != this.hidden) { 
                if (!
    hide) { 
                    
    this.hidden false
                    
    announce(MaplePacketCreator.getGMEffect(0x10, (byte0)); 
                    
    getMap().broadcastMessage(thisMaplePacketCreator.spawnPlayerMapobject(this), false); 
                    
    updatePartyMemberHP(); 
                } else { 
                    
    this.hidden true
                    
    announce(MaplePacketCreator.getGMEffect(0x10, (byte1)); 
                    if (!
    login) { 
                        
    getMap().broadcastMessage(thisMaplePacketCreator.removePlayerFromMap(getId()), false); 
                    } 
                } 
                
    announce(MaplePacketCreator.enableActions()); 
            } 
        } 

        public 
    void Hide(boolean hide) { 
            
    Hide(hidefalse); 
        } 

        public 
    void toggleHide(boolean login) { 
            
    Hide(!isHidden()); 
        } 

        private 
    void cancelFullnessSchedule(int petSlot) { 
            if (
    fullnessSchedule[petSlot] != null) { 
                
    fullnessSchedule[petSlot].cancel(false); 
            } 
        } 

        public 
    void cancelMagicDoor() { 
            for (
    MapleBuffStatValueHolder mbsvh : new ArrayList<>(effects.values())) { 
                if (
    mbsvh.effect.isMagicDoor()) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        public 
    void cancelMapTimeLimitTask() { 
            if (
    mapTimeLimitTask != null) { 
                
    mapTimeLimitTask.cancel(false); 
            } 
        } 

        private 
    void cancelPlayerBuffs(List<MapleBuffStatbuffstats) { 
            if (
    client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null) { 
                
    recalcLocalStats(); 
                
    enforceMaxHpMp(); 
                
    client.announce(MaplePacketCreator.cancelBuff(buffstats)); 
                if (
    buffstats.size() > 0) { 
                    
    getMap().broadcastMessage(thisMaplePacketCreator.cancelForeignBuff(getId(), buffstats), false); 
                } 
            } 
        } 

        public static 
    boolean canCreateChar(String name) { 
            if (
    name.length() < || name.length() > 12) { 
                return 
    false
            } 

            if (
    isInUse(name)) { 
                return 
    false
            } 

            return 
    getIdByName(name) < && !name.toLowerCase().contains("gm") && Pattern.compile("[a-zA-Z0-9_-]{3,12}").matcher(name).matches(); 
        } 

        public 
    boolean canDoor() { 
            return 
    canDoor
        } 

        public 
    FameStatus canGiveFame(MapleCharacter from) { 
            if (
    gmLevel 0) { 
                return 
    FameStatus.OK
            } else if (
    lastfametime >= System.currentTimeMillis() - 3600000 24) { 
                return 
    FameStatus.NOT_TODAY
            } else if (
    lastmonthfameids.contains(Integer.valueOf(from.getId()))) { 
                return 
    FameStatus.NOT_THIS_MONTH
            } else { 
                return 
    FameStatus.OK
            } 
        } 

        public 
    void changeCI(int type) { 
            
    this.ci type
        } 

        public 
    void changeJob(int id) { 
            
    changeJob(MapleJob.getById(id)); 
        } 
             
            public 
    void jobChangingMedalCheck() { 
            if (
    this.getJob().getId() == 100 || this.getJob().getId() == 200 || this.getJob().getId() == 300 || this.getJob().getId() == 400 || this.getJob().getId() == 500) { 
            
    giftMedal(1142107); //adventurer 
            

            if (
    this.getJob().getId() == 110 || this.getJob().getId() == 120 || this.getJob().getId() == 130 || this.getJob().getId() == 210 || this.getJob().getId() == 220 || this.getJob().getId() == 230 || this.getJob().getId() == 310 || this.getJob().getId() == 320 || this.getJob().getId() == 410 || this.getJob().getId() == 420 || this.getJob().getId() == 510 || this.getJob().getId() == 520) { 
            
    giftMedal(1142108);//Jr. adventurer 
            

            if (
    this.getJob().getId() == 111 || this.getJob().getId() == 121 || this.getJob().getId() == 131 || this.getJob().getId() == 211 || this.getJob().getId() == 221 || this.getJob().getId() == 231 || this.getJob().getId() == 311 || this.getJob().getId() == 321 || this.getJob().getId() == 411 || this.getJob().getId() == 421 || this.getJob().getId() == 511 || this.getJob().getId() == 521) { 
            
    giftMedal(1142109); // veteran adv! 
            

            if (
    this.getJob().getId() == 112 || this.getJob().getId() == 122 || this.getJob().getId() == 1322 || this.getJob().getId() == 212 || this.getJob().getId() == 222 || this.getJob().getId() == 232 || this.getJob().getId() == 311 || this.getJob().getId() == 322 || this.getJob().getId() == 412 || this.getJob().getId() == 422 || this.getJob().getId() == 512 || this.getJob().getId() == 522) { 
            
    giftMedal(1142110); // master adv! 
            

            if (
    this.getJob().getId() == 1100 || this.getJob().getId() == 1200 || this.getJob().getId() == 1300 || this.getJob().getId() == 1400 || this.getJob().getId() == 1500) { 
            
    giftMedal(1142066); // training knight 
            

            if (
    this.getJob().getId() == 1110 || this.getJob().getId() == 1210 || this.getJob().getId() == 1310 || this.getJob().getId() == 1410 || this.getJob().getId() == 1510) { 
            
    giftMedal(1142067); // official knight 
            

            if (
    this.getJob().getId() == 1111 || this.getJob().getId() == 1211 || this.getJob().getId() == 1311 || this.getJob().getId() == 1411 || this.getJob().getId() == 1511) { 
            
    giftMedal(1142068); // advanced knight 
            

            if (
    this.getJob().getId() == 1112 || this.getJob().getId() == 1212 || this.getJob().getId() == 1312 || this.getJob().getId() == 1412 || this.getJob().getId() == 1512) { 
            
    giftMedal(1142069); // captain knight 
            

            if (
    this.getJob().getId() == 2100) { 
              
    giftMedal(1142129);  //aran1 
            

            if (
    this.getJob().getId() == 2110) { 
              
    giftMedal(1142130);  //aran2 
            

            if (
    this.getJob().getId() == 2111) { 
              
    giftMedal(1142131);  //aran3 
            

            if (
    this.getJob().getId() == 2112) { 
              
    giftMedal(1142132);  //aran4 
            

        } 

        public 
    void changeJob(MapleJob newJob) { 
            if (
    newJob == null) { 
                return;
    // the fuck you doing idiot! 
            

            
    this.job newJob
            
    this.remainingSp++; 
            if (
    newJob.getId() % 10 == 2) { 
                
    this.remainingSp += 2
            } 
            if (
    newJob.getId() % 10 1) { 
                
    this.remainingAp += 5
            } 
            
    int job_ job.getId() % 1000// lame temp "fix" 
            
    if (job_ == 100) { 
                
    maxhp += Randomizer.next(200250); 
            } else if (
    job_ == 200) { 
                
    maxmp += Randomizer.next(100150); 
            } else if (
    job_ 100 == 0) { 
                
    maxhp += Randomizer.next(100150); 
                
    maxhp += Randomizer.next(2550); 
            } else if (
    job_ && job_ 200) { 
                
    maxhp += Randomizer.next(300350); 
            } else if (
    job_ 300) { 
                
    maxmp += Randomizer.next(450500); 
            } 
    // handle KoC here (undone) 
            
    else if (job_ && job_ != 1000) { 
                
    maxhp += Randomizer.next(300350); 
                
    maxmp += Randomizer.next(150200); 
            } 
            if (
    maxhp >= 30000) { 
                
    maxhp 30000
            } 
            if (
    maxmp >= 30000) { 
                
    maxmp 30000
            } 

            List<
    Pair<MapleStatInteger>> statup = new ArrayList<>(5); 
            
    statup.add(new Pair<>(MapleStat.MAXHPInteger.valueOf(maxhp))); 
            
    statup.add(new Pair<>(MapleStat.MAXMPInteger.valueOf(maxmp))); 
            
    statup.add(new Pair<>(MapleStat.AVAILABLEAPremainingAp)); 
            
    statup.add(new Pair<>(MapleStat.AVAILABLESPremainingSp)); 
            
    statup.add(new Pair<>(MapleStat.JOBInteger.valueOf(job.getId()))); 
            
    recalcLocalStats(); 
            
    client.announce(MaplePacketCreator.updatePlayerStats(statup)); 

            
    silentPartyUpdate(); 
            if (
    this.guildid 0) { 
                
    getGuild().broadcast(MaplePacketCreator.jobMessage(0job.getId(), name), this.getId()); 
            } 
            
    guildUpdate(); 
            
    getMap().broadcastMessage(thisMaplePacketCreator.showForeignEffect(getId(), 8), false); 
        } 

        public 
    void changeKeybinding(int keyMapleKeyBinding keybinding) { 
            if (
    keybinding.getType() != 0) { 
                
    keymap.put(Integer.valueOf(key), keybinding); 
            } else { 
                
    keymap.remove(Integer.valueOf(key)); 
            } 
        } 

        public 
    void changeMap(int map) { 
            
    changeMap(map0); 
        } 

        public 
    void changeMap(int mapint portal) { 
            
    MapleMap warpMap client.getChannelServer().getMapFactory().getMap(map); 
            
    changeMap(warpMapwarpMap.getPortal(portal)); 
        } 

        public 
    void changeMap(int mapString portal) { 
            
    MapleMap warpMap client.getChannelServer().getMapFactory().getMap(map); 
            
    changeMap(warpMapwarpMap.getPortal(portal)); 
        } 

        public 
    void changeMap(int mapMaplePortal portal) { 
            
    MapleMap warpMap client.getChannelServer().getMapFactory().getMap(map); 
            
    changeMap(warpMapportal); 
        } 

        public 
    void changeMap(MapleMap to) { 
            
    changeMap(toto.getPortal(0)); 
        } 

        public 
    void changeMap(final MapleMap to, final MaplePortal pto) { 
            
    changeMapInternal(topto.getPosition(), MaplePacketCreator.getWarpToMap(topto.getId(), this)); 
        } 

        public 
    void changeMap(final MapleMap to, final Point pos) { 
            
    changeMapInternal(toposMaplePacketCreator.getWarpToMap(to0x80this));// Position :O (LEFT) 
        


        public 
    void changeMapBanish(int mapidString portalString msg) { 
            
    dropMessage(5msg); 
            
    MapleMap map_ client.getChannelServer().getMapFactory().getMap(mapid); 
            
    changeMap(map_map_.getPortal(portal)); 
        } 

        private 
    void changeMapInternal(final MapleMap to, final Point pos, final byte[] warpPacket) { 
            
    client.announce(warpPacket); 
            
    map.removePlayer(MapleCharacter.this); 
            if (
    client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null) { 
                
    map to
                
    setPosition(pos); 
                
    map.addPlayer(MapleCharacter.this); 
                if (
    party != null) { 
                    
    mpc.setMapId(to.getId()); 
                    
    silentPartyUpdate(); 
                    
    client.announce(MaplePacketCreator.updateParty(client.getChannel(), partyPartyOperation.SILENT_UPDATEnull)); 
                    
    updatePartyMemberHP(); 
                } 
                if (
    getMap().getHPDec() > 0) { 
                    
    hpDecreaseTask TimerManager.getInstance().schedule(new Runnable() { 
                      [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    doHurtHp(); 
                        } 
                    }, 
    10000); 
                } 
            } 
        } 

        public 
    void changePage(int page) { 
            
    this.currentPage page
        } 

        public 
    void changeSkillLevel(Skill skillbyte newLevelint newMasterlevellong expiration) { 
            if (
    newLevel > -1) { 
                
    skills.put(skill, new SkillEntry(newLevelnewMasterlevelexpiration)); 
                
    this.client.announce(MaplePacketCreator.updateSkill(skill.getId(), newLevelnewMasterlevelexpiration)); 
            } else { 
                
    skills.remove(skill); 
                
    this.client.announce(MaplePacketCreator.updateSkill(skill.getId(), newLevelnewMasterlevel, -1)); // Shouldn't use expiration anymore :) 
                
    try { 
                    
    Connection con DatabaseConnection.getConnection(); 
                    try (
    PreparedStatement ps con.prepareStatement("DELETE FROM skills WHERE skillid = ? AND characterid = ?")) {
                        
    ps.setInt(1skill.getId()); 
                        
    ps.setInt(2id); 
                        
    ps.execute(); 
                    } 
                } catch (
    SQLException ex) { 
                    
    System.out.print("Error deleting skill: " ex); 
                } 
            } 
        } 

        public 
    void changeTab(int tab) { 
            
    this.currentTab tab
        } 

        public 
    void changeType(int type) { 
            
    this.currentType type
        } 

        public 
    void checkBerserk() { 
            if (
    BerserkSchedule != null) { 
                
    BerserkSchedule.cancel(false); 
            } 
            final 
    MapleCharacter chr this
            if (
    job.equals(MapleJob.DARKKNIGHT)) { 
                
    Skill BerserkX SkillFactory.getSkill(DarkKnight.BERSERK); 
                final 
    int skilllevel getSkillLevel(BerserkX); 
                if (
    skilllevel 0) { 
                    
    Berserk chr.getHp() * 100 chr.getMaxHp() < BerserkX.getEffect(skilllevel).getX(); 
                    
    BerserkSchedule TimerManager.getInstance().register(new Runnable() { 
                      [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    client.announce(MaplePacketCreator.showOwnBerserk(skilllevelBerserk)); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showBerserk(getId(), skilllevelBerserk), false); 
                        } 
                    }, 
    50003000); 
                } 
            } 
        } 

        public 
    void checkMessenger() { 
            if (
    messenger != null && messengerposition && messengerposition > -1) { 
                
    World worldz Server.getInstance().getWorld(world); 
                
    worldz.silentJoinMessenger(messenger.getId(), new MapleMessengerCharacter(thismessengerposition), messengerposition); 
                
    worldz.updateMessenger(getMessenger().getId(), nameclient.getChannel()); 
            } 
        } 

        public 
    void checkMonsterAggro(MapleMonster monster) { 
            if (!
    monster.isControllerHasAggro()) { 
                if (
    monster.getController() == this) { 
                    
    monster.setControllerHasAggro(true); 
                } else { 
                    
    monster.switchController(thistrue); 
                } 
            } 
        } 

        public 
    void clearDoors() { 
            
    doors.clear(); 
        } 

        public 
    void clearSavedLocation(SavedLocationType type) { 
            
    savedLocations[type.ordinal()] = null
        } 

        public 
    void controlMonster(MapleMonster monsterboolean aggro) { 
            
    monster.setController(this); 
            
    controlled.add(monster); 
            
    client.announce(MaplePacketCreator.controlMonster(monsterfalseaggro)); 
        } 

        public 
    int countItem(int itemid) { 
            return 
    inventory[MapleItemInformationProvider.getInstance().getInventoryType(itemid).ordinal()].countById(itemid); 
        } 

        public 
    void decreaseBattleshipHp(int decrease) { 
            
    this.battleshipHp -= decrease
            if (
    battleshipHp <= 0) { 
                
    this.battleshipHp 0
                
    Skill battleship SkillFactory.getSkill(Corsair.BATTLE_SHIP); 
                
    int cooldown battleship.getEffect(getSkillLevel(battleship)).getCooldown(); 
                
    announce(MaplePacketCreator.skillCooldown(Corsair.BATTLE_SHIPcooldown)); 
                
    addCooldown(Corsair.BATTLE_SHIPSystem.currentTimeMillis(), cooldownTimerManager.getInstance().schedule(new CancelCooldownAction(thisCorsair.BATTLE_SHIP), cooldown 1000)); 
                
    removeCooldown(5221999); 
                
    cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING); 
            } else { 
                
    announce(MaplePacketCreator.skillCooldown(5221999battleshipHp 10)); // :D 
                
    addCooldown(52219990battleshipHpnull); 
            } 
        } 

        public 
    void decreaseReports() { 
            
    this.possibleReports--; 
        } 

        public 
    void deleteGuild(int guildId) { 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE characters SET guildid = 0, guildrank = 5 WHERE guildid = ?")) { 
                    
    ps.setInt(1guildId); 
                    
    ps.execute(); 
                } 
                try (
    PreparedStatement ps con.prepareStatement("DELETE FROM guilds WHERE guildid = ?")) { 
                    
    ps.setInt(1id); 
                    
    ps.execute(); 
                } 
            } catch (
    SQLException ex) { 
                
    System.out.print("Error deleting guild: " ex); 
            } 
        } 

        private 
    void deleteWhereCharacterId(Connection conString sqlthrows SQLException 
            try (
    PreparedStatement ps con.prepareStatement(sql)) { 
                
    ps.setInt(1id); 
                
    ps.executeUpdate(); 
            } 
        } 

        public static 
    void deleteWhereCharacterId(Connection conString sqlint cidthrows SQLException 
            try (
    PreparedStatement ps con.prepareStatement(sql)) { 
                
    ps.setInt(1cid); 
                
    ps.executeUpdate(); 
            } 
        } 

        private 
    void deregisterBuffStats(List<MapleBuffStatstats) { 
            
    synchronized (stats) { 
                List<
    MapleBuffStatValueHoldereffectsToCancel = new ArrayList<>(stats.size()); 
                for (
    MapleBuffStat stat stats) { 
                    
    MapleBuffStatValueHolder mbsvh effects.get(stat); 
                    if (
    mbsvh != null) { 
                        
    effects.remove(stat); 
                        
    boolean addMbsvh true
                        for (
    MapleBuffStatValueHolder contained effectsToCancel) { 
                            if (
    mbsvh.startTime == contained.startTime && contained.effect == mbsvh.effect) { 
                                
    addMbsvh false
                            } 
                        } 
                        if (
    addMbsvh) { 
                            
    effectsToCancel.add(mbsvh); 
                        } 
                        if (
    stat == MapleBuffStat.RECOVERY) { 
                            if (
    recoveryTask != null) { 
                                
    recoveryTask.cancel(false); 
                                
    recoveryTask null
                            } 
                        } else if (
    stat == MapleBuffStat.SUMMON || stat == MapleBuffStat.PUPPET) { 
                            
    int summonId mbsvh.effect.getSourceId(); 
                            
    MapleSummon summon summons.get(summonId); 
                            if (
    summon != null) { 
                                
    getMap().broadcastMessage(MaplePacketCreator.removeSummon(summontrue), summon.getPosition()); 
                                
    getMap().removeMapObject(summon); 
                                
    removeVisibleMapObject(summon); 
                                
    summons.remove(summonId); 
                            } 
                            if (
    summon.getSkill() == DarkKnight.BEHOLDER) { 
                                if (
    beholderHealingSchedule != null) { 
                                    
    beholderHealingSchedule.cancel(false); 
                                    
    beholderHealingSchedule null
                                } 
                                if (
    beholderBuffSchedule != null) { 
                                    
    beholderBuffSchedule.cancel(false); 
                                    
    beholderBuffSchedule null
                                } 
                            } 
                        } else if (
    stat == MapleBuffStat.DRAGONBLOOD) { 
                            
    dragonBloodSchedule.cancel(false); 
                            
    dragonBloodSchedule null
                        } 
                    } 
                } 
                for (
    MapleBuffStatValueHolder cancelEffectCancelTasks effectsToCancel) { 
                    if (
    cancelEffectCancelTasks.schedule != null) { 
                        
    cancelEffectCancelTasks.schedule.cancel(false); 
                    } 
                } 
            } 
        } 

        public 
    void disableDoor() { 
            
    canDoor false
            
    TimerManager.getInstance().schedule(new Runnable() { 
              [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    canDoor true
                } 
            }, 
    5000); 
        } 

        public 
    void disbandGuild() { 
            if (
    guildid || guildrank != 1) { 
                return; 
            } 
            try { 
                
    Server.getInstance().disbandGuild(guildid); 
            } catch (
    Exception e) { 
            } 
        } 

        public 
    void dispel() { 
            for (
    MapleBuffStatValueHolder mbsvh : new ArrayList<>(effects.values())) { 
                if (
    mbsvh.effect.isSkill()) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        public final List<
    PlayerDiseaseValueHoldergetAllDiseases() { 
            final List<
    PlayerDiseaseValueHolderret = new ArrayList<>(5); 

            
    DiseaseValueHolder vh
            for (
    Entry<MapleDiseaseDiseaseValueHolderdisease diseases.entrySet()) { 
                
    vh disease.getValue(); 
                
    ret.add(new PlayerDiseaseValueHolder(disease.getKey(), vh.startTimevh.length)); 
            } 
            return 
    ret
        } 

        public final 
    boolean hasDisease(final MapleDisease dis) { 
            for (final 
    MapleDisease disease diseases.keySet()) { 
                if (
    disease == dis) { 
                    return 
    true
                } 
            } 
            return 
    false
        } 

        public 
    void giveDebuff(final MapleDisease diseaseMobSkill skill) { 
            final List<
    Pair<MapleDiseaseInteger>> debuff Collections.singletonList(new Pair<>(diseaseInteger.valueOf(skill.getX()))); 

            if (!
    hasDisease(disease) && diseases.size() < 2) { 
                if (!(
    disease == MapleDisease.SEDUCE || disease == MapleDisease.STUN)) { 
                    if (
    isActiveBuffedValue(2321005)) { 
                        return; 
                    } 
                } 
                
    TimerManager.getInstance().schedule(new Runnable() { 
                  [
    MENTION=2000004426]Override[/MENTION
                    public 
    void run() { 
                        
    dispelDebuff(disease); 
                    } 
                }, 
    skill.getDuration()); 

                
    diseases.put(disease, new DiseaseValueHolder(System.currentTimeMillis(), skill.getDuration())); 
                
    client.announce(MaplePacketCreator.giveDebuff(debuffskill)); 
                
    map.broadcastMessage(thisMaplePacketCreator.giveForeignDebuff(iddebuffskill), false); 
            } 
        } 

        public 
    void dispelDebuff(MapleDisease debuff) { 
            if (
    hasDisease(debuff)) { 
                
    long mask debuff.getValue(); 
                
    announce(MaplePacketCreator.cancelDebuff(mask)); 
                
    map.broadcastMessage(thisMaplePacketCreator.cancelForeignDebuff(idmask), false); 

                
    diseases.remove(debuff); 
            } 
        } 

        public 
    void dispelDebuffs() { 
            
    dispelDebuff(MapleDisease.CURSE); 
            
    dispelDebuff(MapleDisease.DARKNESS); 
            
    dispelDebuff(MapleDisease.POISON); 
            
    dispelDebuff(MapleDisease.SEAL); 
            
    dispelDebuff(MapleDisease.WEAKEN); 
        } 

        public 
    void cancelAllDebuffs() { 
            
    diseases.clear(); 
        } 

        public 
    void dispelSkill(int skillid) { 
            
    LinkedList<MapleBuffStatValueHolderallBuffs = new LinkedList<>(effects.values()); 
            for (
    MapleBuffStatValueHolder mbsvh allBuffs) { 
                if (
    skillid == 0) { 
                    if (
    mbsvh.effect.isSkill() && (mbsvh.effect.getSourceId() % 10000000 == 1004 || dispelSkills(mbsvh.effect.getSourceId()))) { 
                        
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                    } 
                } else if (
    mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) { 
                    
    cancelEffect(mbsvh.effectfalsembsvh.startTime); 
                } 
            } 
        } 

        private 
    boolean dispelSkills(int skillid) { 
            switch (
    skillid) { 
                case 
    DarkKnight.BEHOLDER
                case 
    FPArchMage.ELQUINES
                case 
    ILArchMage.IFRIT
                case 
    Priest.SUMMON_DRAGON
                case 
    Bishop.BAHAMUT
                case 
    Ranger.PUPPET
                case 
    Ranger.SILVER_HAWK
                case 
    Sniper.PUPPET
                case 
    Sniper.GOLDEN_EAGLE
                case 
    Hermit.SHADOW_PARTNER
                    return 
    true
                default: 
                    return 
    false
            } 
        } 

        public 
    void doHurtHp() { 
            if (
    this.getInventory(MapleInventoryType.EQUIPPED).findById(getMap().getHPDecProtect()) != null) { 
                return; 
            } 
            
    addHP(-getMap().getHPDec()); 
            
    hpDecreaseTask TimerManager.getInstance().schedule(new Runnable() { 
              [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    doHurtHp(); 
                } 
            }, 
    10000); 
        } 

        public 
    void dropMessage(String message) { 
            
    dropMessage(6message); 
        } 

        public 
    void dropMessage(int typeString message) { 
            if (
    type == -1) { // like in the later versions :D 
                
    client.announce(MaplePacketCreator.earnTitleMessage(message)); 
                return; 
            } 
            
    client.announce(MaplePacketCreator.serverNotice(typemessage)); 
        } 

        public 
    String emblemCost() { 
            return 
    nf.format(MapleGuild.CHANGE_EMBLEM_COST); 
        } 

        public List<
    ScheduledFuture<?>> getTimers() { 
            return timers; 
        } 

        private void enforceMaxHpMp() { 
            List<Pair<MapleStat, Integer>> stats = new ArrayList<>(2); 
            if (getMp() > getCurrentMaxMp()) { 
                setMp(getMp()); 
                stats.add(new Pair<>(MapleStat.MP, Integer.valueOf(getMp()))); 
            } 
            if (getHp() > getCurrentMaxHp()) { 
                setHp(getHp()); 
                stats.add(new Pair<>(MapleStat.HP, Integer.valueOf(getHp()))); 
            } 
            if (stats.size() > 0) { 
                client.announce(MaplePacketCreator.updatePlayerStats(stats)); 
            } 
        } 

        public void enteredScript(String script, int mapid) { 
            if (!entered.containsKey(mapid)) { 
                entered.put(mapid, script); 
            } 
        } 

        public void equipChanged() { 
            getMap().broadcastMessage(this, MaplePacketCreator.updateCharLook(this), false); 
            recalcLocalStats(); 
            enforceMaxHpMp(); 
            if (getMessenger() != null) { 
                Server.getInstance().getWorld(world).updateMessenger(getMessenger(), getName(), getWorld(), client.getChannel()); 
            } 
        } 

        public void cancelExpirationTask() { 
            if (expiretask != null) { 
                expiretask.cancel(false); 
                expiretask = null; 
            } 
        } 

        public void expirationTask() { 
            if (expiretask == null) { 
                expiretask = TimerManager.getInstance().register(new Runnable() { 
                  [MENTION=2000004426]Override[/MENTION] 
                    public void run() { 
                        long expiration, currenttime = System.currentTimeMillis(); 
                        Set<Skill> keys = getSkills().keySet(); 
                        for (Iterator<Skill> i = keys.iterator(); i.hasNext();) { 
                            Skill key = i.next(); 
                            SkillEntry skill = getSkills().get(key); 
                            if (skill.expiration != -1 && skill.expiration < currenttime) { 
                                changeSkillLevel(key, (byte) -1, 0, -1); 
                            } 
                        } 

                        List<Item> toberemove = new ArrayList<>(); 
                        for (MapleInventory inv : inventory) { 
                            for (Item item : inv.list()) { 
                                expiration = item.getExpiration(); 
                                if (expiration != -1 && (expiration < currenttime) && ((item.getFlag() & ItemConstants.LOCK) == ItemConstants.LOCK)) { 
                                    byte aids = item.getFlag(); 
                                    aids &= ~(ItemConstants.LOCK); 
                                    item.setFlag(aids); // Probably need a check, else people can make expiring items into permanent items... 
                                    item.setExpiration(-1); 
                                    forceUpdateItem(item); // TEST :3 
                                } else if (expiration != -1 && expiration < currenttime) { 
                                    client.announce(MaplePacketCreator.itemExpired(item.getItemId())); 
                                    toberemove.add(item); 
                                } 
                            } 
                            for (Item item : toberemove) { 
                                MapleInventoryManipulator.removeFromSlot(client, inv.getType(), item.getPosition(), item.getQuantity(), true); 
                            } 
                            toberemove.clear(); 
                        } 
                    } 
                }, 60000); 
            } 
        } 

        public enum FameStatus { 

            OK, 
            NOT_TODAY, 
            NOT_THIS_MONTH 
        } 

        public void forceUpdateItem(Item item) { 
            final List<ModifyInventory> mods = new LinkedList<>(); 
            mods.add(new ModifyInventory(3, item)); 
            mods.add(new ModifyInventory(0, item)); 
            client.announce(MaplePacketCreator.modifyInventory(true, mods)); 
        } 

        public void gainGachaExp() { 
            int expgain = 0; 
            int currentgexp = gachaexp.get(); 
            if ((currentgexp + exp.get()) >= ExpTable.getExpNeededForLevel(level)) { 
                expgain += ExpTable.getExpNeededForLevel(level) - exp.get(); 
                int nextneed = ExpTable.getExpNeededForLevel(level + 1); 
                if ((currentgexp - expgain) >= nextneed) { 
                    expgain += nextneed; 
                } 
                this.gachaexp.set(currentgexp - expgain); 
            } else { 
                expgain = this.gachaexp.getAndSet(0); 
            } 
            gainExp(expgain, false, false); 
            updateSingleStat(MapleStat.GACHAEXP, this.gachaexp.get()); 
        } 

        public void gainGachaExp(int gain) { 
            updateSingleStat(MapleStat.GACHAEXP, gachaexp.addAndGet(gain)); 
        } 

        public void gainExp(int gain, boolean show, boolean inChat) { 
            gainExp(gain, show, inChat, true); 
        } 

        public void gainExp(int gain, boolean show, boolean inChat, boolean white) { 
            int equip = (gain / 10) * pendantExp; 
            int total = gain + equip; 

            if (level < getMaxLevel()) { 
                if ((long) this.exp.get() + (long) total > (long) Integer.MAX_VALUE) { 
                    int gainFirst = ExpTable.getExpNeededForLevel(level) - this.exp.get(); 
                    total -= gainFirst + 1; 
                    this.gainExp(gainFirst + 1, false, inChat, white); 
                } 
                updateSingleStat(MapleStat.EXP, this.exp.addAndGet(total)); 
                if (show && gain != 0) { 
                    client.announce(MaplePacketCreator.getShowExpGain(gain, equip, inChat, white)); 
                } 

                while (exp.get() >= ExpTable.getExpNeededForLevel(level)) { 
                    levelUp(true); 
                } 
            } 
        } 

        public void gainFame(int delta) { 
            this.addFame(delta); 
            this.updateSingleStat(MapleStat.FAME, this.fame); 
        } 

        public void gainMeso(int gain, boolean show) { 
            gainMeso(gain, show, false, false); 
        } 

        public void gainMeso(int gain, boolean show, boolean enableActions, boolean inChat) { 
            if (meso.get() + gain < 0) { 
                client.announce(MaplePacketCreator.enableActions()); 
                return; 
            } 
            updateSingleStat(MapleStat.MESO, meso.addAndGet(gain), enableActions); 
            if (show) { 
                client.announce(MaplePacketCreator.getShowMesoGain(gain, inChat)); 
            } 
        } 

        public void genericGuildMessage(int code) { 
            this.client.announce(MaplePacketCreator.genericGuildMessage((byte) code)); 
        } 

        public int getAccountID() { 
            return accountid; 
        } 

        public List<PlayerBuffValueHolder> getAllBuffs() { 
            List<PlayerBuffValueHolder> ret = new ArrayList<>(); 
            for (MapleBuffStatValueHolder mbsvh : effects.values()) { 
                ret.add(new PlayerBuffValueHolder(mbsvh.startTime, mbsvh.effect)); 
            } 
            return ret; 
        } 

        public List<PlayerCoolDownValueHolder> getAllCooldowns() { 
            List<PlayerCoolDownValueHolder> ret = new ArrayList<>(); 
            for (MapleCoolDownValueHolder mcdvh : coolDowns.values()) { 
                ret.add(new PlayerCoolDownValueHolder(mcdvh.skillId, mcdvh.startTime, mcdvh.length)); 
            } 
            return ret; 
        } 

        public int getAllianceRank() { 
            return this.allianceRank; 
        } 

        public int getAllowWarpToId() { 
            return warpToId; 
        } 

        public static String getAriantRoomLeaderName(int room) { 
            return ariantroomleader[room]; 
        } 

        public static int getAriantSlotsRoom(int room) { 
            return ariantroomslot[room]; 
        } 

        public int getBattleshipHp() { 
            return battleshipHp; 
        } 

        public BuddyList getBuddylist() { 
            return buddylist; 
        } 

        public static Map<String, String> getCharacterFromDatabase(String name) { 
            Map<String, String> character = new LinkedHashMap<>(); 

            try { 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT `id`, `accountid`, `name` FROM `characters` WHERE `name` = ?")) { 
                    ps.setString(1, name); 
                    try (ResultSet rs = ps.executeQuery()) { 
                        if (!rs.next()) { 
                            rs.close(); 
                            ps.close(); 
                            return null; 
                        } 

                        for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { 
                            character.put(rs.getMetaData().getColumnLabel(i), rs.getString(i)); 
                        } 
                    } 
                } 
            } catch (SQLException sqle) { 
                sqle.printStackTrace(); 
            } 

            return character; 
        } 

        public static boolean isInUse(String name) { 
            return getCharacterFromDatabase(name) != null; 
        } 

        public Long getBuffedStarttime(MapleBuffStat effect) { 
            MapleBuffStatValueHolder mbsvh = effects.get(effect); 
            if (mbsvh == null) { 
                return null; 
            } 
            return Long.valueOf(mbsvh.startTime); 
        } 

        public Integer getBuffedValue(MapleBuffStat effect) { 
            MapleBuffStatValueHolder mbsvh = effects.get(effect); 
            if (mbsvh == null) { 
                return null; 
            } 
            return Integer.valueOf(mbsvh.value); 
        } 

        public int getBuffSource(MapleBuffStat stat) { 
            MapleBuffStatValueHolder mbsvh = effects.get(stat); 
            if (mbsvh == null) { 
                return -1; 
            } 
            return mbsvh.effect.getSourceId(); 
        } 

        private List<MapleBuffStat> getBuffStats(MapleStatEffect effect, long startTime) { 
            List<MapleBuffStat> stats = new ArrayList<>(); 
            for (Entry<MapleBuffStat, MapleBuffStatValueHolder> stateffect : effects.entrySet()) { 
                if (stateffect.getValue().effect.sameSource(effect) && (startTime == -1 || startTime == stateffect.getValue().startTime)) { 
                    stats.add(stateffect.getKey()); 
                } 
            } 
            return stats; 
        } 

        public int getChair() { 
            return chair; 
        } 

        public String getChalkboard() { 
            return this.chalktext; 
        } 

        public MapleClient getClient() { 
            return client; 
        } 

        public final List<MapleQuestStatus> getCompletedQuests() { 
            List<MapleQuestStatus> ret = new LinkedList<>(); 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus().equals(MapleQuestStatus.Status.COMPLETED)) { 
                    ret.add(q); 
                } 
            } 
            return Collections.unmodifiableList(ret); 
        } 

        public Collection<MapleMonster> getControlledMonsters() { 
            return Collections.unmodifiableCollection(controlled); 
        } 

        public List<MapleRing> getCrushRings() { 
            Collections.sort(crushRings); 
            return crushRings; 
        } 

        public int getCurrentCI() { 
            return ci; 
        } 

        public int getCurrentPage() { 
            return currentPage; 
        } 

        public int getCurrentMaxHp() { 
            return localmaxhp; 
        } 

        public int getCurrentMaxMp() { 
            return localmaxmp; 
        } 

        public int getCurrentTab() { 
            return currentTab; 
        } 

        public int getCurrentType() { 
            return currentType; 
        } 

        public int getDex() { 
            return dex; 
        } 

        public int getDojoEnergy() { 
            return dojoEnergy; 
        } 

        public boolean getDojoParty() { 
            return dojoParty; 
        } 

        public int getDojoPoints() { 
            return dojoPoints; 
        } 

        public int getDojoStage() { 
            return dojoStage; 
        } 

        public List<MapleDoor> getDoors() { 
            return new ArrayList<>(doors); 
        } 

        public int getDropRate() { 
            return dropRate; 
        } 

        public int getEnergyBar() { 
            return energybar; 
        } 

        public EventInstanceManager getEventInstance() { 
            return eventInstance; 
        } 

        public ArrayList<Integer> getExcluded() { 
            return excluded; 
        } 

        public int getExp() { 
            return exp.get(); 
        } 

        public int getGachaExp() { 
            return gachaexp.get(); 
        } 

        public int getExpRate() { 
            return expRate; 
        } 

        public int getFace() { 
            return face; 
        } 

        public int getFame() { 
            return fame; 
        } 

        public MapleFamily getFamily() { 
            return family; 
        } 

        public void setFamily(MapleFamily f) { 
            this.family = f; 
        } 

        public int getFamilyId() { 
            return familyId; 
        } 

        public boolean getFinishedDojoTutorial() { 
            return finishedDojoTutorial; 
        } 

        public List<MapleRing> getFriendshipRings() { 
            Collections.sort(friendshipRings); 
            return friendshipRings; 
        } 

        public int getGender() { 
            return gender; 
        } 

        public boolean isMale() { 
            return getGender() == 0; 
        } 

        public MapleGuild getGuild() { 
            try { 
                return Server.getInstance().getGuild(getGuildId(), null); 
            } catch (Exception ex) { 
                return null; 
            } 
        } 

        public int getGuildId() { 
            return guildid; 
        } 

        public int getGuildRank() { 
            return guildrank; 
        } 

        public int getHair() { 
            return hair; 
        } 

        public HiredMerchant getHiredMerchant() { 
            return hiredMerchant; 
        } 

        public int getHp() { 
            return hp; 
        } 

        public int getHpMpApUsed() { 
            return hpMpApUsed; 
        } 

        // NEVER CALL THIS UNLESS... 
        public void setId(int id) { 
            this.id = id; 
        } 

        public int getId() { 
            return id; 
        } 

        public static int getIdByName(String name) { 
            try { 
                int id; 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT id FROM characters WHERE name = ?")) { 
                    ps.setString(1, name); 
                    try (ResultSet rs = ps.executeQuery()) { 
                        if (!rs.next()) { 
                            rs.close(); 
                            ps.close(); 
                            return -1; 
                        } 
                        id = rs.getInt("id"); 
                    } 
                } 
                return id; 
            } catch (Exception e) { 
            } 
            return -1; 
        } 

        public static String getNameById(int id) { 
            try { 
                String name; 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT name FROM characters WHERE id = ?")) { 
                    ps.setInt(1, id); 
                    try (ResultSet rs = ps.executeQuery()) { 
                        if (!rs.next()) { 
                            rs.close(); 
                            ps.close(); 
                            return null; 
                        } 
                        name = rs.getString("name"); 
                    } 
                } 
                return name; 
            } catch (Exception e) { 
            } 
            return null; 
        } 

        public static int getAccountIdByCharacterName(String name) { 
            try { 
                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()) { 
                    return rs.getInt("accountid"); 
                } 
                rs.close(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
            return -1; 
        } 

        public int getInitialSpawnpoint() { 
            return initialSpawnPoint; 
        } 

        public int getInt() { 
            return int_; 
        } 

        public MapleInventory getInventory(MapleInventoryType type) { 
            return inventory[type.ordinal()]; 
        } 

        public int getItemEffect() { 
            return itemEffect; 
        } 

        public int getItemQuantity(int itemid, boolean checkEquipped) { 
            int possesed = inventory[MapleItemInformationProvider.getInstance().getInventoryType(itemid).ordinal()].countById(itemid); 
            if (checkEquipped) { 
                possesed += inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid); 
            } 
            return possesed; 
        } 

        public MapleJob getJob() { 
            return job; 
        } 

        public int getJobRank() { 
            return jobRank; 
        } 

        public int getJobRankMove() { 
            return jobRankMove; 
        } 

        public int getJobType() { 
            return job.getId() / 1000; 
        } 

        public Map<Integer, MapleKeyBinding> getKeymap() { 
            return keymap; 
        } 

        public long getLastHealed() { 
            return lastHealed; 
        } 

        public long getLastUsedCashItem() { 
            return lastUsedCashItem; 
        } 

        public int getLevel() { 
            return level; 
        } 

        public int getLuk() { 
            return luk; 
        } 

        public int getFh() { 
            if (getMap().getFootholds().findBelow(this.getPosition()) == null) { 
                return 0; 
            } else { 
                return getMap().getFootholds().findBelow(this.getPosition()).getId(); 
            } 
        } 

        public MapleMap getMap() { 
            return map; 
        } 

        public int getMapId() { 
            if (map != null) { 
                return map.getId(); 
            } 
            return mapid; 
        } 

        public int getMarkedMonster() { 
            return markedMonster; 
        } 

        public MapleRing getMarriageRing() { 
            return marriageRing; 
        } 

        public int getMarried() { 
            return married; 
        } 

        public int getMasterLevel(Skill skill) { 
            if (skills.get(skill) == null) { 
                return 0; 
            } 
            return skills.get(skill).masterlevel; 
        } 

        public int getMaxHp() { 
            return maxhp; 
        } 

        public int getMaxLevel() { 
            return 200; 
        } 

        public int getMaxMp() { 
            return maxmp; 
        } 

        public void setMeso(int i) { 
            meso.set(i); 
        } 

        public int getMeso() { 
            return meso.get(); 
        } 

        public int getMerchantMeso() { 
            return merchantmeso; 
        } 

        public int getMesoRate() { 
            return mesoRate; 
        } 

        public int getMesosTraded() { 
            return mesosTraded; 
        } 

        public int getMessengerPosition() { 
            return messengerposition; 
        } 

        public MapleGuildCharacter getMGC() { 
            return mgc; 
        } 

        public MaplePartyCharacter getMPC() { 
            // if (mpc == null) mpc = new MaplePartyCharacter(this); 
            return mpc; 
        } 

        public void setMPC(MaplePartyCharacter mpc) { 
            this.mpc = mpc; 
        } 

        public AbstractMinigame getMiniGame() { 
            return miniGame; 
        } 

        public int getMiniGamePoints(String type, boolean omok) { 
            if (omok) { 
                switch (type) { 
                    case "wins": 
                        return omokwins; 
                    case "losses": 
                        return omoklosses; 
                    default: 
                        return omokties; 
                } 
            } else { 
                switch (type) { 
                    case "wins": 
                        return matchcardwins; 
                    case "losses": 
                        return matchcardlosses; 
                    default: 
                        return matchcardties; 
                } 
            } 
        } 

        public MonsterBook getMonsterBook() { 
            return monsterbook; 
        } 

        public int getMonsterBookCover() { 
            return bookCover; 
        } 

        public MapleMount getMount() { 
            return maplemount; 
        } 

        public int getMp() { 
            return mp; 
        } 

        public MapleMessenger getMessenger() { 
            return messenger; 
        } 

        public String getName() { 
            return name; 
        } 

        public int getNextEmptyPetIndex() { 
            for (int i = 0; i < 3; i++) { 
                if (pets[i] == null) { 
                    return i; 
                } 
            } 
            return 3; 
        } 

        public int getNoPets() { 
            int ret = 0; 
            for (int i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    ret++; 
                } 
            } 
            return ret; 
        } 

        public int getNumControlledMonsters() { 
            return controlled.size(); 
        } 

        public MapleParty getParty() { 
            return party; 
        } 

        public int getPartyId() { 
            return (party != null ? party.getId() : -1); 
        } 

        public MaplePlayerShop getPlayerShop() { 
            return playerShop; 
        } 

        public MaplePet[] getPets() { 
            return pets; 
        } 

        public MaplePet getPet(int index) { 
            return pets[index]; 
        } 

        public byte getPetIndex(int petId) { 
            for (byte i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    if (pets[i].getUniqueId() == petId) { 
                        return i; 
                    } 
                } 
            } 
            return -1; 
        } 

        public byte getPetIndex(MaplePet pet) { 
            for (byte i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    if (pets[i].getUniqueId() == pet.getUniqueId()) { 
                        return i; 
                    } 
                } 
            } 
            return -1; 
        } 

        public int getPossibleReports() { 
            return possibleReports; 
        } 

        public final byte getQuestStatus(final int quest) { 
            for (final MapleQuestStatus q : quests.values()) { 
                if (q.getQuest().getId() == quest) { 
                    return (byte) q.getStatus().getId(); 
                } 
            } 
            return 0; 
        } 

        public MapleQuestStatus getQuest(MapleQuest quest) { 
            if (!quests.containsKey(quest)) { 
                return new MapleQuestStatus(quest, MapleQuestStatus.Status.NOT_STARTED); 
            } 
            return quests.get(quest); 
        } 

        public boolean needQuestItem(int questid, int itemid) { 
            if (questid <= 0) { 
                return true; // For non quest items :3 
            } 
            MapleQuest quest = MapleQuest.getInstance(questid); 
            return getInventory(ItemConstants.getInventoryType(itemid)).countById(itemid) < quest.getItemAmountNeeded(itemid); 
        } 

        public int getRank() { 
            return rank; 
        } 

        public int getRankMove() { 
            return rankMove; 
        } 

        public int getRemainingAp() { 
            return remainingAp; 
        } 

        public int getRemainingSp() { 
            return remainingSp; 
        } 

        public int getSavedLocation(String type) { 
            SavedLocation sl = savedLocations[SavedLocationType.fromString(type).ordinal()]; 
            if (sl == null) { 
                return 102000000; 
            } 
            int m = sl.getMapId(); 
            if (!SavedLocationType.fromString(type).equals(SavedLocationType.WORLDTOUR)) { 
                clearSavedLocation(SavedLocationType.fromString(type)); 
            } 
            return m; 
        } 

        public String getSearch() { 
            return search; 
        } 

        public MapleShop getShop() { 
            return shop; 
        } 

        public Map<Skill, SkillEntry> getSkills() { 
            return Collections.unmodifiableMap(skills); 
        } 

        public int getSkillLevel(int skill) { 
            SkillEntry ret = skills.get(SkillFactory.getSkill(skill)); 
            if (ret == null) { 
                return 0; 
            } 
            return ret.skillevel; 
        } 

        public byte getSkillLevel(Skill skill) { 
            if (skills.get(skill) == null) { 
                return 0; 
            } 
            return skills.get(skill).skillevel; 
        } 

        public long getSkillExpiration(int skill) { 
            SkillEntry ret = skills.get(SkillFactory.getSkill(skill)); 
            if (ret == null) { 
                return -1; 
            } 
            return ret.expiration; 
        } 

        public long getSkillExpiration(Skill skill) { 
            if (skills.get(skill) == null) { 
                return -1; 
            } 
            return skills.get(skill).expiration; 
        } 

        public MapleSkinColor getSkinColor() { 
            return skinColor; 
        } 

        public int getSlot() { 
            return slots; 
        } 

        public final List<MapleQuestStatus> getStartedQuests() { 
            List<MapleQuestStatus> ret = new LinkedList<>(); 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus().equals(MapleQuestStatus.Status.STARTED)) { 
                    ret.add(q); 
                } 
            } 
            return Collections.unmodifiableList(ret); 
        } 

        public final int getStartedQuestsSize() { 
            int i = 0; 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus().equals(MapleQuestStatus.Status.STARTED)) { 
                    if (q.getQuest().getInfoNumber() > 0) { 
                        i++; 
                    } 
                    i++; 
                } 
            } 
            return i; 
        } 

        public MapleStatEffect getStatForBuff(MapleBuffStat effect) { 
            MapleBuffStatValueHolder mbsvh = effects.get(effect); 
            if (mbsvh == null) { 
                return null; 
            } 
            return mbsvh.effect; 
        } 

        public MapleStorage getStorage() { 
            return storage; 
        } 

        public int getStr() { 
            return str; 
        } 

        public Map<Integer, MapleSummon> getSummons() { 
            return summons; 
        } 

        public int getTotalLuk() { 
            return localluk; 
        } 

        public int getTotalMagic() { 
            return magic; 
        } 

        public int getTotalWatk() { 
            return watk; 
        } 

        public MapleTrade getTrade() { 
            return trade; 
        } 

        public int getVanquisherKills() { 
            return vanquisherKills; 
        } 

        public int getVanquisherStage() { 
            return vanquisherStage; 
        } 

        public Collection<MapleMapObject> getVisibleMapObjects() { 
            return Collections.unmodifiableCollection(visibleMapObjects); 
        } 

        public int getWorld() { 
            return world; 
        } 

        public void giveCoolDowns(final int skillid, long starttime, long length) { 
            if (skillid == 5221999) { 
                this.battleshipHp = (int) length; 
                addCooldown(skillid, 0, length, null); 
            } else { 
                int time = (int) ((length + starttime) - System.currentTimeMillis()); 
                addCooldown(skillid, System.currentTimeMillis(), time, TimerManager.getInstance().schedule(new CancelCooldownAction(this, skillid), time)); 
            } 
        } 

        public int gmLevel() { 
            return gmLevel; 
        } 

        public String guildCost() { 
            return nf.format(MapleGuild.CREATE_GUILD_COST); 
        } 

        private void guildUpdate() { 
            if (this.guildid < 1) { 
                return; 
            } 
            mgc.setLevel(level); 
            mgc.setJobId(job.getId()); 
            try { 
                Server.getInstance().memberLevelJobUpdate(this.mgc); 
                int allianceId = getGuild().getAllianceId(); 
                if (allianceId > 0) { 
                    Server.getInstance().allianceMessage(allianceId, MaplePacketCreator.updateAllianceJobLevel(this), getId(), -1);
                } 
            } catch (Exception e) { 
                e.printStackTrace(); 
            } 
        } 

        public void handleEnergyChargeGain() { // to get here energychargelevel has to be > 0 
            Skill energycharge = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.ENERGY_CHARGE) : SkillFactory.getSkill(Marauder.ENERGY_CHARGE); 
            MapleStatEffect ceffect; 
            ceffect = energycharge.getEffect(getSkillLevel(energycharge)); 
            TimerManager tMan = TimerManager.getInstance(); 
            if (energybar < 10000) { 
                energybar += 102; 
                if (energybar > 10000) { 
                    energybar = 10000; 
                } 
                List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ENERGY_CHARGE, energybar)); 
                setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energybar); 
                client.announce(MaplePacketCreator.giveBuff(energybar, 0, stat)); 
                client.announce(MaplePacketCreator.showOwnBuffEffect(energycharge.getId(), 2)); 
                getMap().broadcastMessage(this, MaplePacketCreator.showBuffeffect(id, energycharge.getId(), 2)); 
                getMap().broadcastMessage(this, MaplePacketCreator.giveForeignBuff(energybar, stat)); 
            } 
            if (energybar >= 10000 && energybar < 11000) { 
                energybar = 15000; 
                final MapleCharacter chr = this; 
                tMan.schedule(new Runnable() { 
                  [MENTION=2000004426]Override[/MENTION] 
                    public void run() { 
                        energybar = 0; 
                        List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ENERGY_CHARGE, energybar)); 
                        setBuffedValue(MapleBuffStat.ENERGY_CHARGE, energybar); 
                        client.announce(MaplePacketCreator.giveBuff(energybar, 0, stat)); 
                        getMap().broadcastMessage(chr, MaplePacketCreator.giveForeignBuff(energybar, stat)); 
                    } 
                }, ceffect.getDuration()); 
            } 
        } 

        public void handleOrbconsume() { 
            int skillid = isCygnus() ? DawnWarrior.COMBO : Crusader.COMBO; 
            Skill combo = SkillFactory.getSkill(skillid); 
            List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.COMBO, 1)); 
            setBuffedValue(MapleBuffStat.COMBO, 1); 
            client.announce(MaplePacketCreator.giveBuff(skillid, combo.getEffect(getSkillLevel(combo)).getDuration() + (int) ((getBuffedStarttime(MapleBuffStat.COMBO) - System.currentTimeMillis())), stat)); 
            getMap().broadcastMessage(this, MaplePacketCreator.giveForeignBuff(getId(), stat), false); 
        } 

        public boolean hasEntered(String script) { 
            for (int mapId : entered.keySet()) { 
                if (entered.get(mapId).equals(script)) { 
                    return true; 
                } 
            } 
            return false; 
        } 

        public boolean hasEntered(String script, int mapId) { 
            if (entered.containsKey(mapId)) { 
                if (entered.get(mapId).equals(script)) { 
                    return true; 
                } 
            } 
            return false; 
        } 

        public void hasGivenFame(MapleCharacter to) { 
            lastfametime = System.currentTimeMillis(); 
            lastmonthfameids.add(Integer.valueOf(to.getId())); 
            try { 
                try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO famelog (characterid, characterid_to) VALUES (?, ?)")) { 
                    ps.setInt(1, getId()); 
                    ps.setInt(2, to.getId()); 
                    ps.executeUpdate(); 
                } 
            } catch (SQLException e) { 
            } 
        } 

        public boolean hasMerchant() { 
            return hasMerchant; 
        } 

        public boolean haveItem(int itemid) { 
            return getItemQuantity(itemid, false) > 0; 
        } 

        public void increaseGuildCapacity() { // hopefully nothing is null 
            if (getMeso() < getGuild().getIncreaseGuildCost(getGuild().getCapacity())) { 
                dropMessage(1, "You don't have enough mesos."); 
                return; 
            } 
            Server.getInstance().increaseGuildCapacity(guildid); 
            gainMeso(-getGuild().getIncreaseGuildCost(getGuild().getCapacity()), true, false, false); 
        } 

        public boolean isActiveBuffedValue(int skillid) { 
            LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList<>(effects.values()); 
            for (MapleBuffStatValueHolder mbsvh : allBuffs) { 
                if (mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) { 
                    return true; 
                } 
            } 
            return false; 
        } 

        public boolean isAlive() { 
            return hp > 0; 
        } 

        public boolean isBuffFrom(MapleBuffStat stat, Skill skill) { 
            MapleBuffStatValueHolder mbsvh = effects.get(stat); 
            if (mbsvh == null) { 
                return false; 
            } 
            return mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skill.getId(); 
        } 

        public boolean isCygnus() { 
            return getJobType() == 1; 
        } 

        public boolean isAran() { 
            return getJob().getId() >= 2000 && getJob().getId() <= 2112; 
        } 

        public boolean isBeginnerJob() { 
            return (getJob().getId() == 0 || getJob().getId() == 1000 || getJob().getId() == 2000) && getLevel() < 11; 
        } 

        public boolean isGM() { 
            return gmLevel >= 3; 
        } 

        public boolean isHidden() { 
            return hidden; 
        } 

        public boolean isMapObjectVisible(MapleMapObject mo) { 
            return visibleMapObjects.contains(mo); 
        } 

        public boolean isPartyLeader() { 
            return party.getLeader() == party.getMemberById(getId()); 
        } 

        public void leaveMap() { 
            controlled.clear(); 
            visibleMapObjects.clear(); 
            if (chair != 0) { 
                chair = 0; 
            } 
            if (hpDecreaseTask != null) { 
                hpDecreaseTask.cancel(false); 
            } 
        } 
             
            public final void RandomLevelUpBonus(String... aArgs){ 
          MapleCharacter player = getClient().getPlayer(); 
          int cashAmount=(int)(10*Math.random()); 
          getClient().getChannelServer().getPlayerStorage().getCharacterByName(getName()).getCashShop().gainCash(1, cashAmount*100); 
          if (ServerConstants.levelup_bonuses == true) { 
          int randomInt=(int)(100*Math.random()); 
          if (randomInt == 1 && cashAmount*100 > 0) { 
          remainingAp += 5; 
          player.dropMessage("You have gained 5 extra AP and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 1 && cashAmount*100 == 0) { 
          remainingAp += 5; 
          player.dropMessage("You have gained 5 extra AP!"); 
          } 

          if (randomInt == 2 && cashAmount*100 > 0) { 
          player.gainMeso(100000, true); 
          player.dropMessage("You have gained 100,000 Mesos and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 2 && cashAmount*100 == 0) { 
          player.gainMeso(100000, true); 
          player.dropMessage("You have gained 100,000 Mesos!"); 
          } 
          if (randomInt == 3 && cashAmount*100 > 0) { 
          player.gainMeso(40000, true); 
          player.dropMessage("You have gained 40,000 Mesos and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 3 && cashAmount*100 == 0) { 
          player.gainMeso(40000, true); 
          player.dropMessage("You have gained 40,000 Mesos!"); 
          } 
          if (randomInt == 4 && cashAmount*100 > 0 || randomInt == 5 && cashAmount*100 > 0) { 
          player.gainMeso(20000, true); 
          player.dropMessage("You have gained 20,000 Mesos and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 4 && cashAmount*100 == 0 || randomInt == 5 && cashAmount*100 == 0) { 
          player.gainMeso(20000, true); 
          player.dropMessage("You have gained 20,000 Mesos!"); 
          } 
          if (randomInt == 6 && cashAmount*100 > 0) { 
          player.levelUp(false); 
          player.dropMessage("Double level up and " +cashAmount*100 + " NX cash!"); 
          } 
          if (randomInt == 6 && cashAmount*100 == 0) { 
          player.levelUp(false); 
          player.dropMessage("Double level up!"); 
          } 
          if (randomInt == 7 && cashAmount*100 > 0) { 
          int fameAmount=(int)(31*Math.random()+1); 
          player.gainFame(fameAmount); 
          player.dropMessage("You have gained " + fameAmount + " fame and " +cashAmount*100 + " NX cash!"); 
          if (randomInt == 7 && cashAmount*100 == 0) { 
          int fameAmountTwo=(int)(31*Math.random()+1); 
          player.gainFame(fameAmountTwo); 
          player.dropMessage("You have gained " + fameAmount + " fame!"); 
          } 
          if (randomInt > 7 && randomInt < 15) { 
          player.addExpBonus(); 
          player.dropMessage("You have gained an expbonus!"); 
          } 

          } else { 
              if (cashAmount*100 > 0) { 
             // player.dropMessage("You have gained " +cashAmount*100 + " NX cash!"); 
              } 
          } 
     } 
        } 

        public void levelUp(boolean takeexp) { 
            Skill improvingMaxHP = null; 
            Skill improvingMaxMP = null; 
            int improvingMaxHPLevel = 0; 
            int improvingMaxMPLevel = 0; 

            remainingAp += 5; 
            if (isCygnus() && level < 70) { 
                remainingAp++; 
            } 
            if (job == MapleJob.BEGINNER || job == MapleJob.NOBLESSE || job == MapleJob.LEGEND) { 
                maxhp += Randomizer.next(12, 16); 
                maxmp += Randomizer.next(10, 12); 
            } else if (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.DAWNWARRIOR1)) { 
                improvingMaxHP = isCygnus() ? SkillFactory.getSkill(DawnWarrior.MAX_HP_INCREASE) : SkillFactory.getSkill(Swordsman.IMPROVED_MAX_HP_INCREASE); 
                if (job.isA(MapleJob.CRUSADER)) { 
                    improvingMaxMP = SkillFactory.getSkill(1210000); 
                } else if (job.isA(MapleJob.DAWNWARRIOR2)) { 
                    improvingMaxMP = SkillFactory.getSkill(11110000); 
                } 
                improvingMaxHPLevel = getSkillLevel(improvingMaxHP); 
                maxhp += Randomizer.next(24, 28); 
                maxmp += Randomizer.next(4, 6); 
            } else if (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.BLAZEWIZARD1)) { 
                improvingMaxMP = isCygnus() ? SkillFactory.getSkill(BlazeWizard.INCREASING_MAX_MP) : SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE); 
                improvingMaxMPLevel = getSkillLevel(improvingMaxMP); 
                maxhp += Randomizer.next(10, 14); 
                maxmp += Randomizer.next(22, 24); 
            } else if (job.isA(MapleJob.BOWMAN) || job.isA(MapleJob.THIEF) || (job.getId() > 1299 && job.getId() < 1500)) { 
                maxhp += Randomizer.next(20, 24); 
                maxmp += Randomizer.next(14, 16); 
            } else if (job.isA(MapleJob.GM)) { 
                maxhp = 30000; 
                maxmp = 30000; 
            } else if (job.isA(MapleJob.PIRATE) || job.isA(MapleJob.THUNDERBREAKER1)) { 
                improvingMaxHP = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.IMPROVE_MAX_HP) : SkillFactory.getSkill(5100000); 
                improvingMaxHPLevel = getSkillLevel(improvingMaxHP); 
                maxhp += Randomizer.next(22, 28); 
                maxmp += Randomizer.next(18, 23); 
            } else if (job.isA(MapleJob.ARAN1)) { 
                maxhp += Randomizer.next(44, 48); 
                int aids = Randomizer.next(4, 8); 
                maxmp += aids + Math.floor(aids * 0.1); 
            } 
            if (improvingMaxHPLevel > 0 && (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.PIRATE) || job.isA(MapleJob.DAWNWARRIOR1))) { 
                maxhp += improvingMaxHP.getEffect(improvingMaxHPLevel).getX(); 
            } 
            if (improvingMaxMPLevel > 0 && (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.CRUSADER) || job.isA(MapleJob.BLAZEWIZARD1))) { 
                maxmp += improvingMaxMP.getEffect(improvingMaxMPLevel).getX(); 
            } 
            maxmp += localint_ / 10; 
            if (takeexp) { 
                exp.addAndGet(-ExpTable.getExpNeededForLevel(level)); 
                if (exp.get() < 0) { 
                    exp.set(0); 
                } 
            } 
            level++; 
            if (level >= getMaxLevel()) { 
                exp.set(0); 
            } 
            maxhp = Math.min(30000, maxhp); 
            maxmp = Math.min(30000, maxmp); 
            if (level == 200) { 
                exp.set(0); 
            } 
            hp = maxhp; 
            mp = maxmp; 
            recalcLocalStats(); 
            List<Pair<MapleStat, Integer>> statup = new ArrayList<>(10); 
            statup.add(new Pair<>(MapleStat.AVAILABLEAP, remainingAp)); 
            statup.add(new Pair<>(MapleStat.HP, localmaxhp)); 
            statup.add(new Pair<>(MapleStat.MP, localmaxmp)); 
            statup.add(new Pair<>(MapleStat.EXP, exp.get())); 
            statup.add(new Pair<>(MapleStat.LEVEL, level)); 
            statup.add(new Pair<>(MapleStat.MAXHP, maxhp)); 
            statup.add(new Pair<>(MapleStat.MAXMP, maxmp)); 
            statup.add(new Pair<>(MapleStat.STR, str)); 
            statup.add(new Pair<>(MapleStat.DEX, dex)); 
            if (job.getId() % 1000 > 0) { 
                remainingSp += 3; 
                statup.add(new Pair<>(MapleStat.AVAILABLESP, remainingSp)); 
            } 
            client.announce(MaplePacketCreator.updatePlayerStats(statup)); 
            getMap().broadcastMessage(this, MaplePacketCreator.showForeignEffect(getId(), 0), false); 
            recalcLocalStats(); 
            setMPC(new MaplePartyCharacter(this)); 
            silentPartyUpdate(); 
                    RandomLevelUpBonus(); 
            /* 
             * if (this.guildid > 0) { 
             * getGuild().broadcast(MaplePacketCreator.levelUpMessage(2, level, name), this.getId()); 
             * } 
             */ 
            if (ServerConstants.PERFECT_PITCH) { 
                // milestones? 
                if (MapleInventoryManipulator.checkSpace(client, 4310000, (short) 1, "")) { 
                    MapleInventoryManipulator.addById(client, 4310000, (short) 1); 
                } 
            } 
            guildUpdate(); 
        } 

        public static MapleCharacter loadCharFromDB(int charid, MapleClient client, boolean channelserver) throws SQLException { 
            try { 
                MapleCharacter ret = new MapleCharacter(); 
                ret.client = client; 
                ret.id = charid; 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE id = ?"); 
                ps.setInt(1, charid); 
                ResultSet rs = ps.executeQuery(); 
                if (!rs.next()) { 
                    rs.close(); 
                    ps.close(); 
                    throw new RuntimeException("Loading char failed (not found)"); 
                } 
                ret.name = rs.getString("name"); 
                ret.level = rs.getInt("level"); 
                ret.fame = rs.getInt("fame"); 
                ret.str = rs.getInt("str"); 
                ret.dex = rs.getInt("dex"); 
                ret.int_ = rs.getInt("int"); 
                ret.luk = rs.getInt("luk"); 
                ret.exp.set(rs.getInt("exp")); 
                ret.gachaexp.set(rs.getInt("gachaexp")); 
                ret.hp = rs.getInt("hp"); 
                ret.maxhp = rs.getInt("maxhp"); 
                ret.mp = rs.getInt("mp"); 
                ret.maxmp = rs.getInt("maxmp"); 
                ret.hpMpApUsed = rs.getInt("hpMpUsed"); 
                ret.hasMerchant = rs.getInt("HasMerchant") == 1; 
                ret.remainingSp = rs.getInt("sp"); 
                ret.remainingAp = rs.getInt("ap"); 
                ret.meso.set(rs.getInt("meso")); 
                ret.merchantmeso = rs.getInt("MerchantMesos"); 
                ret.gmLevel = rs.getInt("gm"); 
                ret.skinColor = MapleSkinColor.getById(rs.getInt("skincolor")); 
                ret.gender = rs.getInt("gender"); 
                ret.job = MapleJob.getById(rs.getInt("job")); 
                ret.finishedDojoTutorial = rs.getInt("finishedDojoTutorial") == 1; 
                ret.vanquisherKills = rs.getInt("vanquisherKills"); 
                ret.omokwins = rs.getInt("omokwins"); 
                ret.omoklosses = rs.getInt("omoklosses"); 
                ret.omokties = rs.getInt("omokties"); 
                ret.matchcardwins = rs.getInt("matchcardwins"); 
                ret.matchcardlosses = rs.getInt("matchcardlosses"); 
                ret.matchcardties = rs.getInt("matchcardties"); 
                ret.hair = rs.getInt("hair"); 
                ret.face = rs.getInt("face"); 
                ret.accountid = rs.getInt("accountid"); 
                ret.mapid = rs.getInt("map"); 
                ret.initialSpawnPoint = rs.getInt("spawnpoint"); 
                ret.world = rs.getByte("world"); 
                ret.rank = rs.getInt("rank"); 
                ret.rankMove = rs.getInt("rankMove"); 
                ret.jobRank = rs.getInt("jobRank"); 
                ret.jobRankMove = rs.getInt("jobRankMove"); 
                int mountexp = rs.getInt("mountexp"); 
                int mountlevel = rs.getInt("mountlevel"); 
                int mounttiredness = rs.getInt("mounttiredness"); 
                ret.guildid = rs.getInt("guildid"); 
                ret.guildrank = rs.getInt("guildrank"); 
                            ret.legend = rs.getInt("legend"); 
                ret.allianceRank = rs.getInt("allianceRank"); 
                ret.familyId = rs.getInt("familyId"); 
                ret.bookCover = rs.getInt("monsterbookcover"); 
                ret.monsterbook = new MonsterBook(); 
                ret.monsterbook.loadCards(charid); 
                ret.vanquisherStage = rs.getInt("vanquisherStage"); 
                ret.dojoPoints = rs.getInt("dojoPoints"); 
                ret.dojoStage = rs.getInt("lastDojoStage"); 
                ret.reborns = rs.getInt("reborns"); 
                ret.jumppoints = rs.getInt("jumppoints"); 
                ret.jailed = rs.getBoolean("jailed"); 
                ret.jailtime = rs.getLong("jailtime"); 
                ret.jailduration = rs.getLong("jailduration"); 
                ret.eventpoints = rs.getInt("eventpoints"); 
                            ret.legend = rs.getInt("legend"); 
                            ret.horntail_slyed = rs.getInt("horntail_slyed"); 
                            ret.pinkbeen_slyed = rs.getInt("pinkbeen_slyed"); 
                if (rs.getInt("occuid") != -1) 
                    ret.occupation = OccupationEntry.generateEntry(ret, rs.getInt("occuid"), rs.getInt("occulevel"), rs.getInt("occuexp")); 
                if (ret.guildid > 0) { 
                    ret.mgc = new MapleGuildCharacter(ret); 
                } 
                int buddyCapacity = rs.getInt("buddyCapacity"); 
                ret.buddylist = new BuddyList(buddyCapacity); 
                ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(rs.getByte("equipslots")); 
                ret.getInventory(MapleInventoryType.USE).setSlotLimit(rs.getByte("useslots")); 
                ret.getInventory(MapleInventoryType.SETUP).setSlotLimit(rs.getByte("setupslots")); 
                ret.getInventory(MapleInventoryType.ETC).setSlotLimit(rs.getByte("etcslots")); 
                for (Pair<Item, MapleInventoryType> item : ItemFactory.INVENTORY.loadItems(ret.id, !channelserver)) { 
                    ret.getInventory(item.getRight()).addFromDB(item.getLeft()); 
                    Item itemz = item.getLeft(); 
                    if (itemz.getPetId() > -1) { 
                        MaplePet pet = itemz.getPet(); 
                        if (pet != null && pet.isSummoned()) { 
                            ret.addPet(pet); 
                        } 
                        continue; 
                    } 
                    if (item.getRight().equals(MapleInventoryType.EQUIP) || item.getRight().equals(MapleInventoryType.EQUIPPED)) { 
                        Equip equip = (Equip) item.getLeft(); 
                        if (equip.getRingId() > -1) { 
                            MapleRing ring = MapleRing.loadFromDb(equip.getRingId()); 
                            if (item.getRight().equals(MapleInventoryType.EQUIPPED)) { 
                                ring.equip(); 
                            } 
                            if (ring.getItemId() > 1112012) { 
                                ret.addFriendshipRing(ring); 
                            } else { 
                                ret.addCrushRing(ring); 
                            } 
                        } 
                    } 
                } 
                if (channelserver) { 
                    MapleMapFactory mapFactory = client.getChannelServer().getMapFactory(); 
                    ret.map = mapFactory.getMap(ret.mapid); 
                    if (ret.map == null) { 
                        ret.map = mapFactory.getMap(100000000); 
                    } 
                    MaplePortal portal = ret.map.getPortal(ret.initialSpawnPoint); 
                    if (portal == null) { 
                        portal = ret.map.getPortal(0); 
                        ret.initialSpawnPoint = 0; 
                    } 
                    ret.setPosition(portal.getPosition()); 
                    int partyid = rs.getInt("party"); 
                    MapleParty party = Server.getInstance().getWorld(ret.world).getParty(partyid); 
                    if (party != null) { 
                        ret.mpc = party.getMemberById(ret.id); 
                        if (ret.mpc != null) { 
                            ret.party = party; 
                        } 
                    } 
                    int messengerid = rs.getInt("messengerid"); 
                    int position = rs.getInt("messengerposition"); 
                    if (messengerid > 0 && position < 4 && position > -1) { 
                        MapleMessenger messenger = Server.getInstance().getWorld(ret.world).getMessenger(messengerid); 
                        if (messenger != null) { 
                            ret.messenger = messenger; 
                            ret.messengerposition = position; 
                        } 
                    } 
                    ret.loggedIn = true; 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT mapid,vip FROM trocklocations WHERE characterid = ? LIMIT 15"); 
                ps.setInt(1, charid); 
                rs = ps.executeQuery(); 
                byte v = 0; 
                byte r = 0; 
                while (rs.next()) { 
                    if (rs.getInt("vip") == 1) { 
                        ret.viptrockmaps[v] = rs.getInt("mapid"); 
                        v++; 
                    } else { 
                        ret.trockmaps[r] = rs.getInt("mapid"); 
                        r++; 
                    } 
                } 
                while (v < 10) { 
                    ret.viptrockmaps[v] = 999999999; 
                    v++; 
                } 
                while (r < 5) { 
                    ret.trockmaps[r] = 999999999; 
                    r++; 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT name FROM accounts WHERE id = ?", Statement.RETURN_GENERATED_KEYS); 
                ps.setInt(1, ret.accountid); 
                rs = ps.executeQuery(); 
                if (rs.next()) { 
                    ret.getClient().setAccountName(rs.getString("name")); 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT `area`,`info` FROM area_info WHERE charid = ?"); 
                ps.setInt(1, ret.id); 
                rs = ps.executeQuery(); 
                while (rs.next()) { 
                    ret.area_info.put(rs.getShort("area"), rs.getString("info")); 
                } 
                rs.close(); 
                ps.close(); 
                ps = con.prepareStatement("SELECT `name`,`info` FROM eventstats WHERE characterid = ?"); 
                ps.setInt(1, ret.id); 
                rs = ps.executeQuery(); 
                while (rs.next()) { 
                    String name = rs.getString("name"); 
                    if (rs.getString("name").equals("rescueGaga")) { 
                        ret.events.put(name, new RescueGaga(rs.getInt("info"))); 
                    } 
                    // ret.events = new MapleEvents(new RescueGaga(rs.getInt("rescuegaga")), new ArtifactHunt(rs.getInt("artifacthunt"))); 
                } 
                rs.close(); 
                ps.close(); 
                ret.cashshop = new CashShop(ret.accountid, ret.id, ret.getJobType()); 
                ret.autoban = new AutobanManager(ret); 
                ret.marriageRing = null; // for now 
                ps = con.prepareStatement("SELECT name, level FROM characters WHERE accountid = ? AND id != ? ORDER BY level DESC limit 1"); 
                ps.setInt(1, ret.accountid); 
                ps.setInt(2, charid); 
                rs = ps.executeQuery(); 
                if (rs.next()) { 
                    ret.linkedName = rs.getString("name"); 
                    ret.linkedLevel = rs.getInt("level"); 
                } 
                rs.close(); 
                ps.close(); 
                if (channelserver) { 
                    ps = con.prepareStatement("SELECT * FROM queststatus WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    PreparedStatement psf; 
                    try (PreparedStatement pse = con.prepareStatement("SELECT * FROM questprogress WHERE queststatusid = ?")) { 
                        psf = con.prepareStatement("SELECT mapid FROM medalmaps WHERE queststatusid = ?"); 
                        while (rs.next()) { 
                            MapleQuest q = MapleQuest.getInstance(rs.getShort("quest")); 
                            MapleQuestStatus status = new MapleQuestStatus(q, MapleQuestStatus.Status.getById(rs.getInt("status"))); 
                            long cTime = rs.getLong("time"); 
                            if (cTime > -1) { 
                                status.setCompletionTime(cTime * 1000); 
                            } 
                            status.setForfeited(rs.getInt("forfeited")); 
                            ret.quests.put(q, status); 
                            pse.setInt(1, rs.getInt("queststatusid")); 
                            try (ResultSet rsProgress = pse.executeQuery()) { 
                                while (rsProgress.next()) { 
                                    status.setProgress(rsProgress.getInt("progressid"), rsProgress.getString("progress")); 
                                } 
                            } 
                            psf.setInt(1, rs.getInt("queststatusid")); 
                            try (ResultSet medalmaps = psf.executeQuery()) { 
                                while (medalmaps.next()) { 
                                    status.addMedalMap(medalmaps.getInt("mapid")); 
                                } 
                            } 
                        } 
                        rs.close(); 
                        ps.close(); 
                    } 
                    psf.close(); 

                    ps = con.prepareStatement("SELECT * FROM customQuestStatus WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    PreparedStatement pse = con.prepareStatement("SELECT * FROM customQuestMobs WHERE queststatusid = ?"); 
                    while (rs.next()) { 
                        final int id = rs.getInt("quest"); 
                        final CustomQuest q = CustomQuestProvider.getInstance(id); 
                        final MapleCustomQuestStatus status = new MapleCustomQuestStatus(q, rs.getByte("status")); 
                        final long cTime = rs.getLong("time"); 
                        if (cTime > -1) { 
                            status.setCompletionTime(cTime * 1000); 
                        } 
                        status.setCustomData(rs.getString("customData")); 
                        ret.customQuests.put(q, status); 
                        pse.setInt(1, rs.getInt("id")); 
                        final ResultSet rsMobs = pse.executeQuery(); 

                        while (rsMobs.next()) { 
                            status.setMobKills(rsMobs.getInt("mob"), rsMobs.getInt("count")); 
                        } 
                        rsMobs.close(); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    pse.close(); 

                    ps = con.prepareStatement("SELECT skillid,skilllevel,masterlevel,expiration FROM skills WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        ret.skills.put(SkillFactory.getSkill(rs.getInt("skillid")), new SkillEntry(rs.getByte("skilllevel"), rs.getInt("masterlevel"), rs.getLong("expiration"))); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT SkillID,StartTime,length FROM cooldowns WHERE charid = ?"); 
                    ps.setInt(1, ret.getId()); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        final int skillid = rs.getInt("SkillID"); 
                        final long length = rs.getLong("length"), startTime = rs.getLong("StartTime"); 
                        if (skillid != 5221999 && (length + startTime < System.currentTimeMillis())) { 
                            continue; 
                        } 
                        ret.giveCoolDowns(skillid, startTime, length); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("DELETE FROM cooldowns WHERE charid = ?"); 
                    ps.setInt(1, ret.getId()); 
                    ps.executeUpdate(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT * FROM skillmacros WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        int position = rs.getInt("position"); 
                        SkillMacro macro = new SkillMacro(rs.getInt("skill1"), rs.getInt("skill2"), rs.getInt("skill3"), rs.getString("name"), rs.getInt("shout"), position); 
                        ret.skillMacros[position] = macro; 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT `key`,`type`,`action` FROM keymap WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        int key = rs.getInt("key"); 
                        int type = rs.getInt("type"); 
                        int action = rs.getInt("action"); 
                        ret.keymap.put(Integer.valueOf(key), new MapleKeyBinding(type, action)); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT `locationtype`,`map`,`portal` FROM savedlocations WHERE characterid = ?"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    while (rs.next()) { 
                        ret.savedLocations[SavedLocationType.valueOf(rs.getString("locationtype")).ordinal()] = new SavedLocation(rs.getInt("map"), rs.getInt("portal")); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ps = con.prepareStatement("SELECT `characterid_to`,`when` FROM famelog WHERE characterid = ? AND DATEDIFF(NOW(),`when`) < 30"); 
                    ps.setInt(1, charid); 
                    rs = ps.executeQuery(); 
                    ret.lastfametime = 0; 
                    ret.lastmonthfameids = new ArrayList<>(31); 
                    while (rs.next()) { 
                        ret.lastfametime = Math.max(ret.lastfametime, rs.getTimestamp("when").getTime()); 
                        ret.lastmonthfameids.add(Integer.valueOf(rs.getInt("characterid_to"))); 
                    } 
                    rs.close(); 
                    ps.close(); 
                    ret.buddylist.loadFromDb(charid); 
                    ret.storage = MapleStorage.loadOrCreateFromDB(ret.accountid, ret.world); 
                    ret.recalcLocalStats(); 
                    // ret.resetBattleshipHp(); 
                    ret.silentEnforceMaxHpMp(); 
                } 
                int mountid = ret.getJobType() * 10000000 + 1004; 
                if (ret.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18) != null) { 
                    ret.maplemount = new MapleMount(ret, ret.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18).getItemId(), mountid); 
                } else { 
                    ret.maplemount = new MapleMount(ret, 0, mountid); 
                } 
                ret.maplemount.setExp(mountexp); 
                ret.maplemount.setLevel(mountlevel); 
                ret.maplemount.setTiredness(mounttiredness); 
                ret.maplemount.setActive(false); 
                return ret; 
            } catch (SQLException | RuntimeException e) { 
                e.printStackTrace(); 
            } 
            return null; 
        } 

        public static String makeMapleReadable(String in) { 
            String i = in.replace('I', 'i'); 
            i = i.replace('l', 'L'); 
            i = i.replace("rn", "Rn"); 
            i = i.replace("vv", "Vv"); 
            i = i.replace("VV", "Vv"); 
            return i; 

        } 

        private static class MapleBuffStatValueHolder { 

            public MapleStatEffect effect; 
            public long startTime; 
            public int value; 
            public ScheduledFuture<?schedule

            public 
    MapleBuffStatValueHolder(MapleStatEffect effectlong startTimeScheduledFuture<?> 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, length; 
            public ScheduledFuture<?timer

            public 
    MapleCoolDownValueHolder(int skillIdlong startTimelong lengthScheduledFuture<?> timer) { 
                super(); 
                this.skillId = skillId; 
                this.startTime = startTime; 
                this.length = length; 
                this.timer = timer; 
            } 
        } 

        public void message(String m) { 
            dropMessage(5, m); 
        } 

        public void yellowMessage(String m) { 
            announce(MaplePacketCreator.sendYellowTip(m)); 
        } 

        public void mobKilled(int id) { 
            for (MapleQuestStatus q : quests.values()) { 
                if (q.getStatus() == MapleQuestStatus.Status.COMPLETED || q.getQuest().canComplete(this, null)) { 
                    continue; 
                } 
                String progress = q.getProgress(id); 
                if (!progress.isEmpty() && Integer.parseInt(progress) >= q.getQuest().getMobAmountNeeded(id)) { 
                    continue; 
                } 
                if (q.progress(id)) { 
                    client.announce(MaplePacketCreator.updateQuest(q.getQuest().getId(), q.getQuestData())); 
                } 
            } 
        } 

        public void mount(int id, int skillid) { 
            maplemount = new MapleMount(this, id, skillid); 
        } 

        public void playerNPC(MapleCharacter v, int scriptId) { 
            int npcId; 
            try { 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("SELECT id FROM playernpcs WHERE ScriptId = ?"); 
                ps.setInt(1, scriptId); 
                ResultSet rs = ps.executeQuery(); 
                if (!rs.next()) { 
                    rs.close(); 
                    ps = con.prepareStatement("INSERT INTO playernpcs (name, hair, face, skin, x, cy, map, gender, ScriptId, Foothold, rx0, rx1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS); 
                    ps.setString(1, v.getName()); 
                    ps.setInt(2, v.getHair()); 
                    ps.setInt(3, v.getFace()); 
                    ps.setInt(4, v.getSkinColor().getId()); 
                    ps.setInt(5, getPosition().x); 
                    ps.setInt(6, getPosition().y); 
                    ps.setInt(7, getMapId()); 
                    ps.setInt(8, getGender()); 
                    ps.setInt(9, scriptId); 
                    ps.setInt(10, getMap().getFootholds().findBelow(getPosition()).getId()); 
                    ps.setInt(11, getPosition().x); 
                    ps.setInt(12, getPosition().x); 
                    ps.executeUpdate(); 
                    rs = ps.getGeneratedKeys(); 
                    rs.next(); 
                    npcId = rs.getInt(1); 
                    ps.close(); 
                    ps = con.prepareStatement("INSERT INTO playernpcs_equip (NpcId, equipid, equippos) VALUES (?, ?, ?)"); 
                    ps.setInt(1, npcId); 
                    for (Item equip : getInventory(MapleInventoryType.EQUIPPED)) { 
                        int position = Math.abs(equip.getPosition()); 
                        if ((position < 12 && position > 0) || (position > 100 && position < 112)) { 
                            ps.setInt(2, equip.getItemId()); 
                            ps.setInt(3, equip.getPosition()); 
                            ps.addBatch(); 
                        } 
                    } 
                    ps.executeBatch(); 
                    ps.close(); 
                    rs.close(); 
                    ps = con.prepareStatement("SELECT * FROM playernpcs WHERE ScriptId = ?"); 
                    ps.setInt(1, scriptId); 
                    rs = ps.executeQuery(); 
                    rs.next(); 
                    PlayerNPCs pn = new PlayerNPCs(rs); 
                    for (Channel channel : Server.getInstance().getChannelsFromWorld(world)) { 
                        MapleMap m = channel.getMapFactory().getMap(getMapId()); 
                        m.broadcastMessage(MaplePacketCreator.spawnPlayerNPC(pn)); 
                        m.broadcastMessage(MaplePacketCreator.getPlayerNPC(pn)); 
                        m.addMapObject(pn); 
                    } 
                } 
                ps.close(); 
                rs.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        private void playerDead() { 
            cancelAllBuffs(false); 
            dispelDebuffs(); 
            if (getEventInstance() != null) { 
                getEventInstance().playerKilled(this); 
            } 
            int[] charmID = { 5130000, 4031283, 4140903 }; 
            int possesed = 0; 
            int i; 
            for (i = 0; i < charmID.length; i++) { 
                int quantity = getItemQuantity(charmID[i], false); 
                if (possesed == 0 && quantity > 0) { 
                    possesed = quantity; 
                    break; 
                } 
            } 
            if (possesed > 0) { 
                message("You have used a safety charm, so your EXP points have not been decreased."); 
                MapleInventoryManipulator.removeById(client, MapleItemInformationProvider.getInstance().getInventoryType(charmID[i]), charmID[i], 1, true, false); 
            } else if (mapid > 925020000 && mapid < 925030000) { 
                this.dojoStage = 0; 
            } else if (mapid > 980000100 && mapid < 980000700) { 
                getMap().broadcastMessage(this, MaplePacketCreator.CPQDied(this)); 
            } else if (getJob() != MapleJob.BEGINNER) { // Hmm... 
                int XPdummy = ExpTable.getExpNeededForLevel(getLevel()); 
                if (getMap().isTown()) { 
                    XPdummy /= 100; 
                } 
                if (XPdummy == ExpTable.getExpNeededForLevel(getLevel())) { 
                    if (getLuk() <= 100 && getLuk() > 8) { 
                        XPdummy *= (200 - getLuk()) / 2000; 
                    } else if (getLuk() < 8) { 
                        XPdummy /= 10; 
                    } else { 
                        XPdummy /= 20; 
                    } 
                } 
                if (getExp() > XPdummy) { 
                    gainExp(-XPdummy, false, false); 
                } else { 
                    gainExp(-getExp(), false, false); 
                } 
            } 
            if (getBuffedValue(MapleBuffStat.MORPH) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.MORPH); 
            } 

            if (getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING); 
            } 

            if (getChair() == -1) { 
                setChair(0); 
                client.announce(MaplePacketCreator.cancelChair(-1)); 
                getMap().broadcastMessage(this, MaplePacketCreator.showChair(getId(), 0), false); 
            } 
            client.announce(MaplePacketCreator.enableActions()); 
        } 

        private void prepareDragonBlood(final MapleStatEffect bloodEffect) { 
            if (dragonBloodSchedule != null) { 
                dragonBloodSchedule.cancel(false); 
            } 
            dragonBloodSchedule = TimerManager.getInstance().register(new Runnable() { 
              [MENTION=2000004426]Override[/MENTION] 
                public void run() { 
                    addHP(-bloodEffect.getX()); 
                    client.announce(MaplePacketCreator.showOwnBuffEffect(bloodEffect.getSourceId(), 5)); 
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(getId(), bloodEffect.getSourceId(), 5), false); 
                    checkBerserk(); 
                } 
            }, 4000, 4000); 
        } 

        private void recalcLocalStats() { 
            int oldmaxhp = localmaxhp; 
            localmaxhp = getMaxHp(); 
            localmaxmp = getMaxMp(); 
            localdex = getDex(); 
            localint_ = getInt(); 
            localstr = getStr(); 
            localluk = getLuk(); 
            int speed = 100, jump = 100; 
            magic = localint_; 
            watk = 0; 
            for (Item item : getInventory(MapleInventoryType.EQUIPPED)) { 
                Equip equip = (Equip) 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(); 
            } 
            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)) { 
                Skill expert = null; 
                if (job.isA(MapleJob.MARKSMAN)) { 
                    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; 
            // } 
            if (oldmaxhp != 0 && oldmaxhp != localmaxhp) { 
                updatePartyMemberHP(); 
            } 
        } 

        public void receivePartyMemberHP() { 
            if (party != null) { 
                int channel = client.getChannel(); 
                for (MaplePartyCharacter partychar : party.getMembers()) { 
                    if (partychar.getMapId() == getMapId() && partychar.getChannel() == channel) { 
                        MapleCharacter other = Server.getInstance().getWorld(world).getChannel(channel).getPlayerStorage().getCharacterByName(partychar.getName()); 
                        if (other != null) { 
                            client.announce(MaplePacketCreator.updatePartyMemberHP(other.getId(), other.getHp(), other.getCurrentMaxHp())); 
                        } 
                    } 
                } 
            } 
        } 

        public void registerEffect(MapleStatEffect effect, long starttime, ScheduledFuture<?schedule) { 
            if (
    effect.isDragonBlood()) { 
                
    prepareDragonBlood(effect); 
            } else if (
    effect.isBerserk()) { 
                
    checkBerserk(); 
            } else if (
    effect.isBeholder()) { 
                final 
    int beholder DarkKnight.BEHOLDER
                if (
    beholderHealingSchedule != null) { 
                    
    beholderHealingSchedule.cancel(false); 
                } 
                if (
    beholderBuffSchedule != null) { 
                    
    beholderBuffSchedule.cancel(false); 
                } 
                
    Skill bHealing SkillFactory.getSkill(DarkKnight.AURA_OF_BEHOLDER); 
                
    int bHealingLvl getSkillLevel(bHealing); 
                if (
    bHealingLvl 0) { 
                    final 
    MapleStatEffect healEffect bHealing.getEffect(bHealingLvl); 
                    
    int healInterval healEffect.getX() * 1000
                    
    beholderHealingSchedule TimerManager.getInstance().register(new Runnable() { 
                      [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    addHP(healEffect.getHp()); 
                            
    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder2)); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.summonSkill(getId(), beholder5), true); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showOwnBuffEffect(beholder2), false); 
                        } 
                    }, 
    healIntervalhealInterval); 
                } 
                
    Skill bBuff SkillFactory.getSkill(DarkKnight.HEX_OF_BEHOLDER); 
                if (
    getSkillLevel(bBuff) > 0) { 
                    final 
    MapleStatEffect buffEffect bBuff.getEffect(getSkillLevel(bBuff)); 
                    
    int buffInterval buffEffect.getX() * 1000
                    
    beholderBuffSchedule TimerManager.getInstance().register(new Runnable() { 
                      [
    MENTION=2000004426]Override[/MENTION
                        public 
    void run() { 
                            
    buffEffect.applyTo(MapleCharacter.this); 
                            
    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder2)); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.summonSkill(getId(), beholder, (int) (Math.random() * 3) + 6), true); 
                            
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showBuffeffect(getId(), beholder2), false); 
                        } 
                    }, 
    buffIntervalbuffInterval); 
                } 
            } else if (
    effect.isRecovery()) { 
                final 
    byte heal = (byteeffect.getX(); 
                
    recoveryTask TimerManager.getInstance().register(new Runnable() { 
                  [
    MENTION=2000004426]Override[/MENTION
                    public 
    void run() { 
                        
    addHP(heal); 
                        
    client.announce(MaplePacketCreator.showOwnRecovery(heal)); 
                        
    getMap().broadcastMessage(MapleCharacter.thisMaplePacketCreator.showRecovery(idheal), false); 
                    } 
                }, 
    50005000); 
            } 
            for (
    Pair<MapleBuffStatIntegerstatup effect.getStatups()) { 
                
    effects.put(statup.getLeft(), new MapleBuffStatValueHolder(effectstarttimeschedulestatup.getRight().intValue())); 
            } 
            
    recalcLocalStats(); 
        } 

        public 
    void removeAllCooldownsExcept(int id) { 
            for (
    MapleCoolDownValueHolder mcvh coolDowns.values()) { 
                if (
    mcvh.skillId != id) { 
                    
    coolDowns.remove(mcvh.skillId); 
                } 
            } 
        } 

        public static 
    void removeAriantRoom(int room) { 
            
    ariantroomleader[room] = ""
            
    ariantroomslot[room] = 0
        } 

        public 
    void removeCooldown(int skillId) { 
            if (
    this.coolDowns.containsKey(skillId)) { 
                
    this.coolDowns.remove(skillId); 
            } 
        } 

        public 
    void removePet(MaplePet petboolean shift_left) { 
            
    int slot = -1
            for (
    int i 03i++) { 
                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 slot3i++) { 
                        if (
    != 2) { 
                            
    pets[i] = pets[1]; 
                        } else { 
                            
    pets[i] = null
                        } 
                    } 
                } 
            } 
        } 

        public 
    void removeVisibleMapObject(MapleMapObject mo) { 
            
    visibleMapObjects.remove(mo); 
        } 

        public 
    void resetStats() { 
            List<
    Pair<MapleStatInteger>> statup = new ArrayList<>(5); 
            
    int tap 0tsp 1
            
    int tstr 4tdex 4tint 4tluk 4
            
    int levelap = (isCygnus() ? 5); 
            switch (
    job.getId()) { 
                case 
    100
                case 
    1100
                case 
    2100:// ? 
                    
    tstr 35
                    
    tap = ((getLevel() - 10) * levelap) + 14
                    
    tsp += ((getLevel() - 10) * 3); 
                    break; 
                case 
    200
                case 
    1200
                    
    tint 20
                    
    tap = ((getLevel() - 8) * levelap) + 29
                    
    tsp += ((getLevel() - 8) * 3); 
                    break; 
                case 
    300
                case 
    1300
                case 
    400
                case 
    1400
                    
    tdex 25
                    
    tap = ((getLevel() - 10) * levelap) + 24
                    
    tsp += ((getLevel() - 10) * 3); 
                    break; 
                case 
    500
                case 
    1500
                    
    tdex 20
                    
    tap = ((getLevel() - 10) * levelap) + 29
                    
    tsp += ((getLevel() - 10) * 3); 
                    break; 
            } 
            
    this.remainingAp tap
            
    this.remainingSp tsp
            
    this.dex tdex
            
    this.int_ tint
            
    this.str tstr
            
    this.luk tluk
            
    statup.add(new Pair<>(MapleStat.AVAILABLEAPtap)); 
            
    statup.add(new Pair<>(MapleStat.AVAILABLESPtsp)); 
            
    statup.add(new Pair<>(MapleStat.STRtstr)); 
            
    statup.add(new Pair<>(MapleStat.DEXtdex)); 
            
    statup.add(new Pair<>(MapleStat.INTtint)); 
            
    statup.add(new Pair<>(MapleStat.LUKtluk)); 
            
    announce(MaplePacketCreator.updatePlayerStats(statup)); 
        } 

        public 
    void resetBattleshipHp() { 
            
    this.battleshipHp 4000 getSkillLevel(SkillFactory.getSkill(Corsair.BATTLE_SHIP)) + ((getLevel() - 120) * 2000); 
        } 

        public 
    void resetEnteredScript() { 
            if (
    entered.containsKey(map.getId())) { 
                
    entered.remove(map.getId()); 
            } 
        } 

        public 
    void resetEnteredScript(int mapId) { 
            if (
    entered.containsKey(mapId)) { 
                
    entered.remove(mapId); 
            } 
        } 

        public 
    void resetEnteredScript(String script) { 
            for (
    int mapId entered.keySet()) { 
                if (
    entered.get(mapId).equals(script)) { 
                    
    entered.remove(mapId); 
                } 
            } 
        } 

        public 
    void resetMGC() { 
            
    this.mgc null
        } 

        public 
    void saveCooldowns() { 
            if (
    getAllCooldowns().size() > 0) { 
                try { 
                    
    Connection con DatabaseConnection.getConnection(); 
                    
    deleteWhereCharacterId(con"DELETE FROM cooldowns WHERE charid = ?"); 
                    try (
    PreparedStatement ps con.prepareStatement("INSERT INTO cooldowns (charid, SkillID, StartTime, length) VALUES (?, ?, ?, ?)")) { 
                        
    ps.setInt(1getId()); 
                        for (
    PlayerCoolDownValueHolder cooling getAllCooldowns()) { 
                            
    ps.setInt(2cooling.skillId); 
                            
    ps.setLong(3cooling.startTime); 
                            
    ps.setLong(4cooling.length); 
                            
    ps.addBatch(); 
                        } 
                        
    ps.executeBatch(); 
                    } 
                } catch (
    SQLException se) { 
                } 
            } 
        } 

        public 
    void saveGuildStatus() { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET guildid = ?, guildrank = ?, allianceRank = ? WHERE id = ?")) { 
                    
    ps.setInt(1guildid); 
                    
    ps.setInt(2guildrank); 
                    
    ps.setInt(3allianceRank); 
                    
    ps.setInt(4id); 
                    
    ps.execute(); 
                } 
            } catch (
    SQLException se) { 
            } 
        } 

        public 
    void saveLocation(String type) { 
            
    MaplePortal closest map.findClosestPortal(getPosition()); 
            
    savedLocations[SavedLocationType.fromString(type).ordinal()] = new SavedLocation(getMapId(), closest != null closest.getId() : 0); 
        } 

        public final 
    boolean saveNewCharToDB() { 
            final 
    Connection con DatabaseConnection.getConnection(); 
            
    PreparedStatement ps null

            try { 
                
    con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); 
                
    con.setAutoCommit(false); 
                
    ps con.prepareStatement("INSERT INTO characters (str, dex, luk, `int`, gm, skincolor, gender, job, hair, face, map, meso, spawnpoint, accountid, name, world, equipslots, useslots, setupslots, etcslots, occuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"DatabaseConnection.RETURN_GENERATED_KEYS); 
                
    ps.setInt(112); 
                
    ps.setInt(25); 
                
    ps.setInt(34); 
                
    ps.setInt(44); 
                
    ps.setInt(5gmLevel); 
                
    ps.setInt(6skinColor.getId()); 
                
    ps.setInt(7gender); 
                
    ps.setInt(8getJob().getId()); 
                
    ps.setInt(9hair); 
                
    ps.setInt(10face); 
                
    ps.setInt(11mapid); 
                
    ps.setInt(12Math.abs(meso.get())); 
                
    ps.setInt(130); 
                
    ps.setInt(14accountid); 
                
    ps.setString(15name); 
                
    ps.setInt(16world); 
                
    ps.setInt(1796); 
                
    ps.setInt(1896); 
                
    ps.setInt(1996); 
                
    ps.setInt(2096); 
                
    ps.setInt(21, -1); 
                
    int updateRows ps.executeUpdate(); 
                if (
    updateRows 1) { 
                    
    ps.close(); 
                    
    FilePrinter.printError(FilePrinter.INSERT_CHAR"Error trying to insert " name); 
                    return 
    false
                } 
                
    ResultSet rs ps.getGeneratedKeys(); 
                if (
    rs.next()) { 
                    
    this.id rs.getInt(1); 
                    
    rs.close(); 
                    
    ps.close(); 
                } else { 
                    
    rs.close(); 
                    
    ps.close(); 
                    
    FilePrinter.printError(FilePrinter.INSERT_CHAR"Inserting char failed " name); 
                    return 
    false
                    
    // throw new RuntimeException("Inserting char failed."); 
                


                
    ps con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    int i 0DEFAULT_KEY.lengthi++) { 
                    
    ps.setInt(2DEFAULT_KEY[i]); 
                    
    ps.setInt(3DEFAULT_TYPE[i]); 
                    
    ps.setInt(4DEFAULT_ACTION[i]); 
                    
    ps.execute(); 
                } 
                
    ps.close(); 

                final List<
    Pair<ItemMapleInventoryType>> itemsWithType = new ArrayList<>(); 

                for (
    MapleInventory iv inventory) { 
                    for (
    Item item iv.list()) { 
                        
    itemsWithType.add(new Pair<>(itemiv.getType())); 
                    } 
                } 

                
    ItemFactory.INVENTORY.saveItems(itemsWithTypeid); 

                
    /* 
                 * //jobs start with skills :| 
                 * ps = con.prepareStatement("INSERT INTO skills (characterid, skillid, skilllevel, masterlevel, expiration) VALUES (?, ?, ?, ?, ?)"); 
                 * ps.setInt(1, id); 
                 * for (final Entry<Skill, SkillEntry> skill : skills.entrySet()) { 
                 * ps.setInt(2, skill.getKey().getId()); 
                 * ps.setInt(3, skill.getValue().skillevel); 
                 * ps.setInt(4, skill.getValue().masterlevel); 
                 * ps.setLong(5, skill.getValue().expiration); 
                 * ps.execute(); 
                 * } 
                 * ps.close(); 
                 *  
                 * //sometimes starts with quests too :| 
                 * ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `forfeited`) VALUES (DEFAULT, ?, ?, ?, ?, ?)", DatabaseConnection.RETURN_GENERATED_KEYS); 
                 * try (PreparedStatement pse = con.prepareStatement("INSERT INTO questprogress VALUES (DEFAULT, ?, ?, ?)")) { 
                 * ps.setInt(1, id); 
                 * for (MapleQuestStatus q : quests.values()) { 
                 * ps.setInt(2, q.getQuest().getId()); 
                 * ps.setInt(3, q.getStatus().getId()); 
                 * ps.setLong(4, q.getCompletionTime()); 
                 * ps.setInt(5, q.getForfeited()); 
                 * ps.executeUpdate(); 
                 * try (ResultSet rse = ps.getGeneratedKeys()) { 
                 * rse.next(); 
                 * for (int mob : q.getProgress().keySet()) { 
                 * pse.setInt(1, rse.getInt(1)); 
                 * pse.setInt(2, mob); 
                 * pse.setString(3, q.getProgress(mob)); 
                 * pse.addBatch(); 
                 * } 
                 * pse.executeBatch(); 
                 * } 
                 * } 
                 * } don't think this is needed for v83 
                 */ 

                
    con.commit(); 
                return 
    true
            } catch (
    Throwable t) { 
                
    System.out.println(t); 
                
    FilePrinter.printError(FilePrinter.INSERT_CHARt"Error creating " name " Level: " level " Job: " job.getId()); 
                try { 
                    
    con.rollback(); 
                } catch (
    SQLException se) { 
                    
    FilePrinter.printError(FilePrinter.INSERT_CHARse"Error trying to rollback " name); 
                } 
                return 
    false
            } finally { 
                try { 
                    if (
    ps != null && !ps.isClosed()) { 
                        
    ps.close(); 
                    } 
                    
    con.setAutoCommit(true); 
                    
    con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); 
                } catch (
    SQLException e) { 
                } 
            } 
        } 

        public 
    void saveToDB() { 
            
    Connection con DatabaseConnection.getConnection(); 
            try { 
                
    con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); 
                
    con.setAutoCommit(false); 
                
    PreparedStatement ps
                
    ps con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, gachaexp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpMpUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, mountlevel = ?, mountexp = ?, mounttiredness= ?, equipslots = ?, useslots = ?, setupslots = ?, etcslots = ?,  monsterbookcover = ?, vanquisherStage = ?, dojoPoints = ?, lastDojoStage = ?, finishedDojoTutorial = ?, vanquisherKills = ?, matchcardwins = ?, matchcardlosses = ?, matchcardties = ?, omokwins = ?, omoklosses = ?, omokties = ?, reborns = ?, name = ?, jumppoints = ?, jailed = ?, jailtime = ?, jailduration = ?, eventpoints = ?, occuid = ?, occulevel = ?, occuexp = ?, legend = ?, horntail_slyed = ?, pinkbeen_slyed = ? WHERE id = ?"Statement.RETURN_GENERATED_KEYS); // horntail_slyed = ?, pinkbeen_slyed = ?, 
                
    if (gmLevel && level 199) { 
                    
    ps.setInt(1isCygnus() ? 120 200); 
                } else { 
                    
    ps.setInt(1level); 
                } 
                
    ps.setInt(2fame); 
                
    ps.setInt(3str); 
                
    ps.setInt(4dex); 
                
    ps.setInt(5luk); 
                
    ps.setInt(6int_); 
                
    ps.setInt(7Math.abs(exp.get())); 
                
    ps.setInt(8Math.abs(gachaexp.get())); 
                
    ps.setInt(9hp); 
                
    ps.setInt(10mp); 
                
    ps.setInt(11maxhp); 
                
    ps.setInt(12maxmp); 
                
    ps.setInt(13remainingSp); 
                
    ps.setInt(14remainingAp); 
                
    ps.setInt(15gmLevel); 
                
    ps.setInt(16skinColor.getId()); 
                
    ps.setInt(17gender); 
                
    ps.setInt(18job.getId()); 
                
    ps.setInt(19hair); 
                
    ps.setInt(20face); 
                if (
    map == null || (cashshop != null && cashshop.isOpened())) { 
                    
    ps.setInt(21mapid); 
                } else { 
                    if (
    map.getForcedReturnId() != 999999999) { 
                        
    ps.setInt(21map.getForcedReturnId()); 
                    } else { 
                        
    ps.setInt(21getHp() < map.getReturnMapId() : map.getId()); 
                    } 
                } 
                
    ps.setInt(22meso.get()); 
                
    ps.setInt(23hpMpApUsed); 
                if (
    map == null || map.getId() == 610020000 || map.getId() == 610020001) { 
                    
    ps.setInt(240); 
                } else { 
                    
    MaplePortal closest map.findClosestSpawnpoint(getPosition()); 
                    if (
    closest != null) { 
                        
    ps.setInt(24closest.getId()); 
                    } else { 
                        
    ps.setInt(240); 
                    } 
                } 
                if (
    party != null) { 
                    
    ps.setInt(25party.getId()); 
                } else { 
                    
    ps.setInt(25, -1); 
                } 
                
    ps.setInt(26buddylist.getCapacity()); 
                if (
    messenger != null) { 
                    
    ps.setInt(27messenger.getId()); 
                    
    ps.setInt(28messengerposition); 
                } else { 
                    
    ps.setInt(270); 
                    
    ps.setInt(284); 
                } 
                if (
    maplemount != null) { 
                    
    ps.setInt(29maplemount.getLevel()); 
                    
    ps.setInt(30maplemount.getExp()); 
                    
    ps.setInt(31maplemount.getTiredness()); 
                } else { 
                    
    ps.setInt(291); 
                    
    ps.setInt(300); 
                    
    ps.setInt(310); 
                } 
                for (
    int i 15i++) { 
                    
    ps.setInt(31getSlots(i)); 
                } 

                
    monsterbook.saveCards(getId()); 

                
    ps.setInt(36bookCover); 
                
    ps.setInt(37vanquisherStage); 
                
    ps.setInt(38dojoPoints); 
                
    ps.setInt(39dojoStage); 
                
    ps.setInt(40finishedDojoTutorial 0); 
                
    ps.setInt(41vanquisherKills); 
                
    ps.setInt(42matchcardwins); 
                
    ps.setInt(43matchcardlosses); 
                
    ps.setInt(44matchcardties); 
                
    ps.setInt(45omokwins); 
                
    ps.setInt(46omoklosses); 
                
    ps.setInt(47omokties); 
                
    ps.setInt(48reborns); 
                
    ps.setString(49name); 
                
    ps.setInt(50jumppoints); 
                
    ps.setBoolean(51jailed); 
                
    ps.setLong(52jailtime); 
                
    ps.setLong(53jailduration); 
                
    ps.setInt(54eventpoints); 
                
    ps.setInt(55occupation != null occupation.getInfo().getId() : -1); 
                
    ps.setInt(56occupation != null occupation.getLevel() : 0); 
                
    ps.setInt(57occupation != null occupation.getExp() : 0); 
                            
    ps.setInt(58legend); 
                            
    ps.setInt(59horntail_slyed); 
                            
    ps.setInt(60pinkbeen_slyed); 
                            
    ps.setInt(61id); 

                
    int updateRows ps.executeUpdate(); 
                if (
    updateRows 1) { 
                    throw new 
    RuntimeException("Character not in database (" id ")"); 
                } 
                for (
    int i 03i++) { 
                    if (
    pets[i] != null) { 
                        
    pets[i].saveToDb(); 
                    } 
                } 
                
    deleteWhereCharacterId(con"DELETE FROM keymap WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    Entry<IntegerMapleKeyBindingkeybinding keymap.entrySet()) { 
                    
    ps.setInt(2keybinding.getKey().intValue()); 
                    
    ps.setInt(3keybinding.getValue().getType()); 
                    
    ps.setInt(4keybinding.getValue().getAction()); 
                    
    ps.addBatch(); 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM skillmacros WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO skillmacros (characterid, skill1, skill2, skill3, name, shout, position) VALUES (?, ?, ?, ?, ?, ?, ?)"); 
                
    ps.setInt(1getId()); 
                for (
    int i 05i++) { 
                    
    SkillMacro macro skillMacros[i]; 
                    if (
    macro != null) { 
                        
    ps.setInt(2macro.getSkill1()); 
                        
    ps.setInt(3macro.getSkill2()); 
                        
    ps.setInt(4macro.getSkill3()); 
                        
    ps.setString(5macro.getName()); 
                        
    ps.setInt(6macro.getShout()); 
                        
    ps.setInt(7i); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                List<
    Pair<ItemMapleInventoryType>> itemsWithType = new ArrayList<>(); 

                for (
    MapleInventory iv inventory) { 
                    for (
    Item item iv.list()) { 
                        
    itemsWithType.add(new Pair<>(itemiv.getType())); 
                    } 
                } 

                
    ItemFactory.INVENTORY.saveItems(itemsWithTypeid); 
                
    deleteWhereCharacterId(con"DELETE FROM skills WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO skills (characterid, skillid, skilllevel, masterlevel, expiration) VALUES (?, ?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    Entry<SkillSkillEntryskill skills.entrySet()) { 
                    
    ps.setInt(2skill.getKey().getId()); 
                    
    ps.setInt(3skill.getValue().skillevel); 
                    
    ps.setInt(4skill.getValue().masterlevel); 
                    
    ps.setLong(5skill.getValue().expiration); 
                    
    ps.addBatch(); 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM savedlocations WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO savedlocations (characterid, `locationtype`, `map`, `portal`) VALUES (?, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    SavedLocationType savedLocationType SavedLocationType.values()) { 
                    if (
    savedLocations[savedLocationType.ordinal()] != null) { 
                        
    ps.setString(2savedLocationType.name()); 
                        
    ps.setInt(3savedLocations[savedLocationType.ordinal()].getMapId()); 
                        
    ps.setInt(4savedLocations[savedLocationType.ordinal()].getPortal()); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM trocklocations WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 0)"); 
                for (
    int i 0getTrockSize(); i++) { 
                    if (
    trockmaps[i] != 999999999) { 
                        
    ps.setInt(1getId()); 
                        
    ps.setInt(2trockmaps[i]); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    ps con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 1)"); 
                for (
    int i 0getVipTrockSize(); i++) { 
                    if (
    viptrockmaps[i] != 999999999) { 
                        
    ps.setInt(1getId()); 
                        
    ps.setInt(2viptrockmaps[i]); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM buddies WHERE characterid = ? AND pending = 0"); 
                
    ps con.prepareStatement("INSERT INTO buddies (characterid, `buddyid`, `pending`, `group`) VALUES (?, ?, 0, ?)"); 
                
    ps.setInt(1id); 
                for (
    BuddylistEntry entry buddylist.getBuddies()) { 
                    if (
    entry.isVisible()) { 
                        
    ps.setInt(2entry.getCharacterId()); 
                        
    ps.setString(3entry.getGroup()); 
                        
    ps.addBatch(); 
                    } 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM area_info WHERE charid = ?"); 
                
    ps con.prepareStatement("INSERT INTO area_info (id, charid, area, info) VALUES (DEFAULT, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (
    Entry<ShortStringarea area_info.entrySet()) { 
                    
    ps.setInt(2area.getKey()); 
                    
    ps.setString(3area.getValue()); 
                    
    ps.addBatch(); 
                } 
                
    ps.executeBatch(); 
                
    deleteWhereCharacterId(con"DELETE FROM eventstats WHERE characterid = ?"); 
                
    deleteWhereCharacterId(con"DELETE FROM queststatus WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `forfeited`) VALUES (DEFAULT, ?, ?, ?, ?, ?)"Statement.RETURN_GENERATED_KEYS); 
                
    PreparedStatement psf
                try (
    PreparedStatement pse con.prepareStatement("INSERT INTO questprogress VALUES (DEFAULT, ?, ?, ?)")) { 
                    
    psf con.prepareStatement("INSERT INTO medalmaps VALUES (DEFAULT, ?, ?)"); 
                    
    ps.setInt(1id); 
                    for (
    MapleQuestStatus q quests.values()) { 
                        
    ps.setInt(2q.getQuest().getId()); 
                        
    ps.setInt(3q.getStatus().getId()); 
                        
    ps.setInt(4, (int) (q.getCompletionTime() / 1000)); 
                        
    ps.setInt(5q.getForfeited()); 
                        
    ps.executeUpdate(); 
                        try (
    ResultSet rs ps.getGeneratedKeys()) { 
                            
    rs.next(); 
                            for (
    int mob q.getProgress().keySet()) { 
                                
    pse.setInt(1rs.getInt(1)); 
                                
    pse.setInt(2mob); 
                                
    pse.setString(3q.getProgress(mob)); 
                                
    pse.addBatch(); 
                            } 
                            for (
    int i 0q.getMedalMaps().size(); i++) { 
                                
    psf.setInt(1rs.getInt(1)); 
                                
    psf.setInt(2q.getMedalMaps().get(i)); 
                                
    psf.addBatch(); 
                            } 
                            
    pse.executeBatch(); 
                            
    psf.executeBatch(); 
                        } 
                    } 
                } 
                
    psf.close(); 

                
    deleteWhereCharacterId(con"DELETE FROM customQuestStatus WHERE characterid = ?"); 
                
    ps con.prepareStatement("INSERT INTO customQuestStatus (`id`, `characterid`, `quest`, `status`, `time`, `customData`) VALUES (DEFAULT, ?, ?, ?, ?, ?)"Statement.RETURN_GENERATED_KEYS); 
                
    PreparedStatement pse con.prepareStatement("INSERT INTO customQuestMobs VALUES (DEFAULT, ?, ?, ?)"); 
                
    ps.setInt(1id); 
                for (final 
    MapleCustomQuestStatus q customQuests.values()) { 
                    
    ps.setInt(2q.getQuest().getQuestId()); 
                    
    ps.setInt(3q.getStatus()); 
                    
    ps.setInt(4, (int) (q.getCompletionTime() / 1000)); 
                    
    ps.setString(5q.getCustomData()); 
                    
    ps.executeUpdate(); 
                    
    ResultSet rs ps.getGeneratedKeys(); 
                    
    rs.next(); 

                    if (
    q.hasMobKills()) { 
                        for (
    int mob q.getMobKills().keySet()) { 
                            
    pse.setInt(1rs.getInt(1)); 
                            
    pse.setInt(2mob); 
                            
    pse.setInt(3q.getMobKills(mob)); 
                            
    pse.executeUpdate(); 
                        } 
                    } 
                    
    rs.close(); 
                } 
                
    ps.close(); 
                
    pse.close(); 

                
    ps con.prepareStatement("UPDATE accounts SET gm = ? WHERE id = ?"); 
                
    ps.setInt(1gmLevel); 
                
    ps.setInt(2client.getAccID()); 
                
    ps.executeUpdate(); 
                if (
    cashshop != null) { 
                    
    cashshop.save(); 
                } 
                if (
    storage != null) { 
                    
    storage.saveToDB(); 
                } 
                
    ps.close(); 
                
    con.commit(); 
            } catch (
    SQLException RuntimeException t) { 
                
    FilePrinter.printError(FilePrinter.SAVE_CHARt"Error saving " name " Level: " level " Job: " job.getId()); 
                try { 
                    
    con.rollback(); 
                } catch (
    SQLException se) { 
                    
    FilePrinter.printError(FilePrinter.SAVE_CHARse"Error trying to rollback " name); 
                } 
            } finally { 
                try { 
                    
    con.setAutoCommit(true); 
                    
    con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); 
                } catch (
    Exception e) { 
                } 
            } 
        } 

        public 
    void sendPolice(String reasonint duration) { 
            
    announce(MaplePacketCreator.sendPolice("You have been banned from " ServerConstants.SERVER_NAME ".")); 
            
    this.isbanned true
            
    TimerManager.getInstance().schedule(new Runnable() { 
              [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    client.disconnect(falsefalse); // FAGGOTS 
                

            }, 
    duration); 
        } 

        public 
    void sendPolice(String text) { 
            
    announce(MaplePacketCreator.sendPolice(text)); 
            
    this.isbanned true
            
    TimerManager.getInstance().schedule(new Runnable() { 
              [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    client.disconnect(falsefalse); // FAGGOTS 
                

            }, 
    6000); 
        } 

        public 
    void sendKeymap() { 
            
    client.announce(MaplePacketCreator.getKeymap(keymap)); 
        } 

        public 
    void sendMacros() { 
            
    boolean macros false
            for (
    int i 05i++) { 
                if (
    skillMacros[i] != null) { 
                    
    macros true
                } 
            } 
            if (
    macros) { 
                
    client.announce(MaplePacketCreator.getMacros(skillMacros)); 
            } 
        } 

        public 
    void sendNote(String toString msgbyte famethrows SQLException 
            try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("INSERT INTO notes (`to`, `from`, `message`, `timestamp`, `fame`) VALUES (?, ?, ?, ?, ?)"Statement.RETURN_GENERATED_KEYS)) { 
                
    ps.setString(1to); 
                
    ps.setString(2this.getName()); 
                
    ps.setString(3msg); 
                
    ps.setLong(4System.currentTimeMillis()); 
                
    ps.setByte(5fame); 
                
    ps.executeUpdate(); 
            } 
        } 

        public 
    void setAllianceRank(int rank) { 
            
    allianceRank rank
            if (
    mgc != null) { 
                
    mgc.setAllianceRank(rank); 
            } 
        } 

        public 
    void setAllowWarpToId(int id) { 
            
    this.warpToId id
        } 

        public static 
    void setAriantRoomLeader(int roomString charname) { 
            
    ariantroomleader[room] = charname
        } 

        public static 
    void setAriantSlotRoom(int roomint slot) { 
            
    ariantroomslot[room] = slot
        } 

        public 
    void setBattleshipHp(int battleshipHp) { 
            
    this.battleshipHp battleshipHp
        } 

        public 
    void setBuddyCapacity(int capacity) { 
            
    buddylist.setCapacity(capacity); 
            
    client.announce(MaplePacketCreator.updateBuddyCapacity(capacity)); 
        } 

        public 
    void setBuffedValue(MapleBuffStat effectint value) { 
            
    MapleBuffStatValueHolder mbsvh effects.get(effect); 
            if (
    mbsvh == null) { 
                return; 
            } 
            
    mbsvh.value value
        } 

        public 
    void setChair(int chair) { 
            
    this.chair chair
        } 

        public 
    void setChalkboard(String text) { 
            
    this.chalktext text
        } 

        public 
    void setDex(int dex) { 
            
    this.dex dex
            
    recalcLocalStats(); 
        } 

        public 
    void setDojoEnergy(int x) { 
            
    this.dojoEnergy x
        } 

        public 
    void setDojoParty(boolean b) { 
            
    this.dojoParty b
        } 

        public 
    void setDojoPoints(int x) { 
            
    this.dojoPoints x
        } 

        public 
    void setDojoStage(int x) { 
            
    this.dojoStage x
        } 

        public 
    void setDojoStart() { 
            
    this.dojoMap map
            
    int stage = (map.getId() / 100) % 100
            
    this.dojoFinish System.currentTimeMillis() + (stage 36 15 stage 5) * 60000
        } 

        public 
    void setRates() { 
            
    /* 
             * Calendar cal = Calendar.getInstance(); 
             * cal.setTimeZone(TimeZone.getTimeZone("GMT-8")); 
             * int hr = cal.get(Calendar.HOUR_OF_DAY); 
             * if ((haveItem(5360001) && hr > 6 && hr < 12) || (haveItem(5360002) && hr > 9 && hr < 15) || (haveItem(536000) && hr > 12 && hr < 18) || (haveItem(5360004) && hr > 15 && hr < 21) || (haveItem(536000) && hr > 18) || (haveItem(5360006) && hr < 5) || (haveItem(5360007) && hr > 2 && hr < 6) || (haveItem(5360008) && hr >= 6 && hr < 11)) { 
             * this.dropRate = 2 * worldz.getDropRate(); 
             * this.mesoRate = 2 * worldz.getMesoRate(); 
             * } else { 
             * this.dropRate = worldz.getDropRate(); 
             * this.mesoRate = worldz.getMesoRate(); 
             * } 
             * if ((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) || haveItem(5211048)) { 
             * if (isBeginnerJob()) { 
             * this.expRate = 2; 
             * } else { 
             * this.expRate = 2 * worldz.getExpRate(); 
             * } 
             * } else { 
             * if (isBeginnerJob()) { 
             * this.expRate = 1; 
             * } else { 
             * this.expRate = worldz.getExpRate(); 
             * } 
             * } 
             */ 

            
    World worldz Server.getInstance().getWorld(world); 
            
    this.expRate worldz.getExpRate(); 
            
    this.mesoRate worldz.getMesoRate(); 
            
    this.dropRate worldz.getDropRate(); 
        } 

        public 
    void setEnergyBar(int set) { 
            
    energybar set
        } 

        public 
    void setEventInstance(EventInstanceManager eventInstance) { 
            
    this.eventInstance eventInstance
        } 

        public 
    void setExp(int amount) { 
            
    this.exp.set(amount); 
        } 

        public 
    void setGachaExp(int amount) { 
            
    this.gachaexp.set(amount); 
        } 

        public 
    void setFace(int face) { 
            
    this.face face
        } 

        public 
    void setFame(int fame) { 
            
    this.fame fame
        } 

        public 
    void setFamilyId(int familyId) { 
            
    this.familyId familyId
        } 

        public 
    void setFinishedDojoTutorial() { 
            
    this.finishedDojoTutorial true
        } 

        public 
    void setGender(int gender) { 
            
    this.gender gender
        } 

        public 
    void setGM(int level) { 
            
    this.gmLevel level
        } 

        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 setHair(int hair) { 
            
    this.hair hair
        } 

        public 
    void setHasMerchant(boolean set) { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = ? WHERE id = ?")) { 
                    
    ps.setInt(1set 0); 
                    
    ps.setInt(2id); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
                
    e.printStackTrace(); 
            } 
            
    hasMerchant set
        } 

        public 
    void addMerchantMesos(int add) { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?"Statement.RETURN_GENERATED_KEYS)) { 
                    
    ps.setInt(1merchantmeso add); 
                    
    ps.setInt(2id); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
                return; 
            } 
            
    merchantmeso += add
        } 

        public 
    void setMerchantMeso(int set) { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?"Statement.RETURN_GENERATED_KEYS)) { 
                    
    ps.setInt(1set); 
                    
    ps.setInt(2id); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
                return; 
            } 
            
    merchantmeso set
        } 

        public 
    void setHiredMerchant(HiredMerchant merchant) { 
            
    this.hiredMerchant merchant
        } 

        public 
    void setHp(int newhp) { 
            
    setHp(newhpfalse); 
        } 

        public 
    void setHp(int newhpboolean silent) { 
            
    int oldHp hp
            
    int thp newhp
            if (
    thp 0) { 
                
    thp 0
            } 
            if (
    thp localmaxhp) { 
                
    thp localmaxhp
            } 
            
    this.hp thp
            if (!
    silent) { 
                
    updatePartyMemberHP(); 
            } 
            if (
    oldHp hp && !isAlive()) { 
                
    playerDead(); 
            } 
        } 

        public 
    void setHpMpApUsed(int mpApUsed) { 
            
    this.hpMpApUsed mpApUsed
        } 

        public 
    void setHpMp(int x) { 
            
    setHp(x); 
            
    setMp(x); 
            
    updateSingleStat(MapleStat.HPhp); 
            
    updateSingleStat(MapleStat.MPmp); 
        } 

        public 
    void setInt(int int_) { 
            
    this.int_ int_
            
    recalcLocalStats(); 
        } 

        public 
    void setInventory(MapleInventoryType typeMapleInventory inv) { 
            
    inventory[type.ordinal()] = inv
        } 

        public 
    void setItemEffect(int itemEffect) { 
            
    this.itemEffect itemEffect
        } 

        public 
    void setJob(MapleJob job) { 
            
    this.job job
        } 

        public 
    void setLastHealed(long time) { 
            
    this.lastHealed time
        } 

        public 
    void setLastUsedCashItem(long time) { 
            
    this.lastUsedCashItem time
        } 

        public 
    void setLevel(int level) { 
            
    this.level level
        } 

        public 
    void setLuk(int luk) { 
            
    this.luk luk
            
    recalcLocalStats(); 
        } 

        public 
    void setMap(int PmapId) { 
            
    this.mapid PmapId
        } 

        public 
    void setMap(MapleMap newmap) { 
            
    this.map newmap
        } 

        public 
    void setMarkedMonster(int markedMonster) { 
            
    this.markedMonster markedMonster
        } 

        public 
    void setMaxHp(int hp) { 
            
    this.maxhp hp
            
    recalcLocalStats(); 
        } 

        public 
    void setMaxHp(int hpboolean ap) { 
            
    hp Math.min(30000hp); 
            if (
    ap) { 
                
    setHpMpApUsed(getHpMpApUsed() + 1); 
            } 
            
    this.maxhp hp
            
    recalcLocalStats(); 
        } 

        public 
    void setMaxMp(int mp) { 
            
    this.maxmp mp
            
    recalcLocalStats(); 
        } 

        public 
    void setMaxMp(int mpboolean ap) { 
            
    mp Math.min(30000mp); 
            if (
    ap) { 
                
    setHpMpApUsed(getHpMpApUsed() + 1); 
            } 
            
    this.maxmp mp
            
    recalcLocalStats(); 
        } 

        public 
    void setMessenger(MapleMessenger messenger) { 
            
    this.messenger messenger
        } 

        public 
    void setMessengerPosition(int position) { 
            
    this.messengerposition position
        } 

        public 
    void setMiniGame(AbstractMinigame miniGame) { 
            
    this.miniGame miniGame
        } 

        public 
    void setMiniGamePoints(MapleCharacter visitorint winnerslotboolean omok) { 
            if (
    omok) { 
                if (
    winnerslot == 1) { 
                    
    this.omokwins++; 
                    
    visitor.omoklosses++; 
                } else if (
    winnerslot == 2) { 
                    
    visitor.omokwins++; 
                    
    this.omoklosses++; 
                } else { 
                    
    this.omokties++; 
                    
    visitor.omokties++; 
                } 
            } else { 
                if (
    winnerslot == 1) { 
                    
    this.matchcardwins++; 
                    
    visitor.matchcardlosses++; 
                } else if (
    winnerslot == 2) { 
                    
    visitor.matchcardwins++; 
                    
    this.matchcardlosses++; 
                } else { 
                    
    this.matchcardties++; 
                    
    visitor.matchcardties++; 
                } 
            } 
        } 

        public 
    void setMonsterBookCover(int bookCover) { 
            
    this.bookCover bookCover
        } 

        public 
    void setMp(int newmp) { 
            
    int tmp newmp
            if (
    tmp 0) { 
                
    tmp 0
            } 
            if (
    tmp localmaxmp) { 
                
    tmp localmaxmp
            } 
            
    this.mp tmp
        } 

        public 
    void setName(String name) { 
            
    this.name name
        } 

        public 
    void setParty(MapleParty party) { 
            if (
    party == null) { 
                
    this.mpc null
            } 
            
    this.party party
        } 

        public 
    void setPlayerShop(MaplePlayerShop playerShop) { 
            
    this.playerShop playerShop
        } 

        public 
    void setRemainingAp(int remainingAp) { 
            
    this.remainingAp remainingAp
        } 

        public 
    void setRemainingSp(int remainingSp) { 
            
    this.remainingSp remainingSp
        } 

        public 
    void setSearch(String find) { 
            
    search find
        } 

        public 
    void setSkinColor(MapleSkinColor skinColor) { 
            
    this.skinColor skinColor
        } 

        public 
    byte getSlots(int type) { 
            return 
    type == MapleInventoryType.CASH.getType() ? 96 inventory[type].getSlotLimit(); 
        } 

        public 
    boolean gainSlots(int typeint slots) { 
            return 
    gainSlots(typeslotstrue); 
        } 

        public 
    boolean gainSlots(int typeint slotsboolean update) { 
            
    slots += inventory[type].getSlotLimit(); 
            if (
    slots <= 96) { 
                
    inventory[type].setSlotLimit(slots); 

                
    saveToDB(); 
                if (
    update) { 
                    
    client.announce(MaplePacketCreator.updateInventorySlotLimit(typeslots)); 
                } 

                return 
    true
            } 

            return 
    false
        } 

        public 
    void setShop(MapleShop shop) { 
            
    this.shop shop
        } 

        public 
    void setSlot(int slotid) { 
            
    slots slotid
        } 

        public 
    void setStr(int str) { 
            
    this.str str
            
    recalcLocalStats(); 
        } 

        public 
    void setTrade(MapleTrade trade) { 
            
    this.trade trade
        } 

        public 
    void setVanquisherKills(int x) { 
            
    this.vanquisherKills x
        } 

        public 
    void setVanquisherStage(int x) { 
            
    this.vanquisherStage x
        } 

        public 
    void setWorld(int world) { 
            
    this.world world
        } 

        public 
    void shiftPetsRight() { 
            if (
    pets[2] == null) { 
                
    pets[2] = pets[1]; 
                
    pets[1] = pets[0]; 
                
    pets[0] = null
            } 
        } 

        public 
    void showDojoClock() { 
            
    int stage = (map.getId() / 100) % 100
            
    long time
            if (
    stage == 1) { 
                
    time = (stage 36 15 stage 5) * 60
            } else { 
                
    time = (dojoFinish System.currentTimeMillis()) / 1000
            } 
            if (
    stage 0) { 
                
    client.announce(MaplePacketCreator.getClock((int) time)); 
            } 
            
    boolean rightmap true
            
    int clockid = (dojoMap.getId() / 100) % 100
            if (
    map.getId() > clockid || map.getId() < clockid 6) { 
                
    rightmap false
            } 
            final 
    boolean rightMap rightmap// lol 
            
    TimerManager.getInstance().schedule(new Runnable() { 
              [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    if (
    rightMap) { 
                        
    client.getPlayer().changeMap(client.getChannelServer().getMapFactory().getMap(925020000)); 
                    } 
                } 
            }, 
    time 1000 3000); // let the TIMES UP display for 3 seconds, then warp 
        


        public 
    void showNote() { 
            try { 
                try (
    PreparedStatement ps DatabaseConnection.getConnection().prepareStatement("SELECT * FROM notes WHERE `to`=? AND `deleted` = 0"ResultSet.TYPE_SCROLL_SENSITIVEResultSet.CONCUR_UPDATABLE)) { 
                    
    ps.setString(1this.getName()); 
                    try (
    ResultSet rs ps.executeQuery()) { 
                        
    rs.last(); 
                        
    int count rs.getRow(); 
                        
    rs.first(); 
                        
    client.announce(MaplePacketCreator.showNotes(rscount)); 
                    } 
                } 
            } catch (
    SQLException e) { 
            } 
        } 

        private 
    void silentEnforceMaxHpMp() { 
            
    setMp(getMp()); 
            
    setHp(getHp(), true); 
        } 

        public 
    void silentGiveBuffs(List<PlayerBuffValueHolderbuffs) { 
            for (
    PlayerBuffValueHolder mbsvh buffs) { 
                
    mbsvh.effect.silentApplyBuff(thismbsvh.startTime); 
            } 
        } 

        public 
    void silentPartyUpdate() { 
            if (
    party != null) { 
                
    Server.getInstance().getWorld(world).updateParty(party.getId(), PartyOperation.SILENT_UPDATEgetMPC()); 
            } 
        } 

        public static class 
    SkillEntry 

            public 
    int masterlevel
            public 
    byte skillevel
            public 
    long expiration

            public 
    SkillEntry(byte skillevelint masterlevellong expiration) { 
                
    this.skillevel skillevel
                
    this.masterlevel masterlevel
                
    this.expiration expiration
            } 

          [
    MENTION=2000004426]Override[/MENTION
            public 
    String toString() { 
                return 
    skillevel ":" masterlevel
            } 
        } 

        public 
    boolean skillisCooling(int skillId) { 
            return 
    coolDowns.containsKey(Integer.valueOf(skillId)); 
        } 

        public 
    void startFullnessSchedule(final int decrease, final MaplePet petint petSlot) { 
            
    ScheduledFuture<?> schedule; 
            schedule = TimerManager.getInstance().register(new Runnable() { 
              [MENTION=2000004426]Override[/MENTION] 
                public void run() { 
                    int newFullness = pet.getFullness() - decrease; 
                    if (newFullness <= 5) { 
                        pet.setFullness(15); 
                        pet.saveToDb(); 
                        unequipPet(pet, true); 
                    } else { 
                        pet.setFullness(newFullness); 
                        pet.saveToDb(); 
                        Item petz = getInventory(MapleInventoryType.CASH).getItem(pet.getPosition()); 
                        forceUpdateItem(petz); 
                    } 
                } 
            }, 180000, 18000); 
            fullnessSchedule[petSlot] = schedule; 

        } 

        public void startMapEffect(String msg, int itemId) { 
            startMapEffect(msg, itemId, 30000); 
        } 

        public void startMapEffect(String msg, int itemId, int duration) { 
            final MapleMapEffect mapEffect = new MapleMapEffect(msg, itemId); 
            getClient().announce(mapEffect.makeStartData()); 
            TimerManager.getInstance().schedule(new Runnable() { 
              [MENTION=2000004426]Override[/MENTION] 
                public void run() { 
                    getClient().announce(mapEffect.makeDestroyData()); 
                } 
            }, duration); 
        } 

        public void stopControllingMonster(MapleMonster monster) { 
            controlled.remove(monster); 
        } 

        public void unequipAllPets() { 
            for (int i = 0; i < 3; i++) { 
                if (pets[i] != null) { 
                    unequipPet(pets[i], true); 
                } 
            } 
        } 

        public void unequipPet(MaplePet pet, boolean shift_left) { 
            unequipPet(pet, shift_left, false); 
        } 

        public void unequipPet(MaplePet pet, boolean shift_left, boolean hunger) { 
            if (this.getPet(this.getPetIndex(pet)) != null) { 
                this.getPet(this.getPetIndex(pet)).setSummoned(false); 
                this.getPet(this.getPetIndex(pet)).saveToDb(); 
            } 
            cancelFullnessSchedule(getPetIndex(pet)); 
            getMap().broadcastMessage(this, MaplePacketCreator.showPet(this, pet, true, hunger), true); 
            client.announce(MaplePacketCreator.petStatUpdate(this)); 
            client.announce(MaplePacketCreator.enableActions()); 
            removePet(pet, shift_left); 
        } 

        public void updateMacros(int position, SkillMacro updateMacro) { 
            skillMacros[position] = updateMacro; 
        } 

        public void updatePartyMemberHP() { 
            if (party != null) { 
                int channel = client.getChannel(); 
                for (MaplePartyCharacter partychar : party.getMembers()) { 
                    if (partychar.getMapId() == getMapId() && partychar.getChannel() == channel) { 
                        MapleCharacter other = Server.getInstance().getWorld(world).getChannel(channel).getPlayerStorage().getCharacterByName(partychar.getName()); 
                        if (other != null) { 
                            other.client.announce(MaplePacketCreator.updatePartyMemberHP(getId(), this.hp, maxhp)); 
                        } 
                    } 
                } 
            } 
        } 

        public void updateQuest(MapleQuestStatus quest) { 
            quests.put(quest.getQuest(), quest); 
            if (quest.getStatus().equals(MapleQuestStatus.Status.STARTED)) { 
                announce(MaplePacketCreator.questProgress((short) quest.getQuest().getId(), quest.getProgress(0))); 
                if (quest.getQuest().getInfoNumber() > 0) { 
                    announce(MaplePacketCreator.questProgress(quest.getQuest().getInfoNumber(), Integer.toString(quest.getMedalProgress()))); 
                } 
                announce(MaplePacketCreator.updateQuestInfo((short) quest.getQuest().getId(), quest.getNpc())); 
            } else if (quest.getStatus().equals(MapleQuestStatus.Status.COMPLETED)) { 
                announce(MaplePacketCreator.completeQuest((short) quest.getQuest().getId(), quest.getCompletionTime())); 
            } else if (quest.getStatus().equals(MapleQuestStatus.Status.NOT_STARTED)) { 
                announce(MaplePacketCreator.forfeitQuest((short) quest.getQuest().getId())); 
            } 
        } 

        public void questTimeLimit(final MapleQuest quest, int time) { 
            ScheduledFuture<?sf TimerManager.getInstance().schedule(new Runnable() { 
              [
    MENTION=2000004426]Override[/MENTION
                public 
    void run() { 
                    
    announce(MaplePacketCreator.questExpire(quest.getId())); 
                    
    MapleQuestStatus newStatus = new MapleQuestStatus(questMapleQuestStatus.Status.NOT_STARTED); 
                    
    newStatus.setForfeited(getQuest(quest).getForfeited() + 1); 
                    
    updateQuest(newStatus); 
                } 
            }, 
    time); 
            
    announce(MaplePacketCreator.addQuestTimeLimit(quest.getId(), time)); 
            
    timers.add(sf); 
        } 

        public 
    void updateSingleStat(MapleStat statint newval) { 
            
    updateSingleStat(statnewvalfalse); 
        } 

        private 
    void updateSingleStat(MapleStat statint newvalboolean itemReaction) { 
            
    announce(MaplePacketCreator.updatePlayerStats(Collections.singletonList(new Pair<>(statInteger.valueOf(newval))), itemReaction)); 
        } 

        public 
    void announce(final byte[] packet) { 
            
    client.announce(packet); 
        } 

      [
    MENTION=2000004426]Override[/MENTION
        public 
    int getObjectId() { 
            return 
    getId(); 
        } 

      [
    MENTION=2000004426]Override[/MENTION
        public 
    MapleMapObjectType getType() { 
            return 
    MapleMapObjectType.PLAYER
        } 

      [
    MENTION=2000004426]Override[/MENTION
        public 
    void sendDestroyData(MapleClient client) { 
            
    client.announce(MaplePacketCreator.removePlayerFromMap(this.getObjectId())); 
        } 

      [
    MENTION=2000004426]Override[/MENTION
        public 
    void sendSpawnData(MapleClient client) { 
            if (!
    this.isHidden() || client.getPlayer().gmLevel() > 0) { 
                
    client.announce(MaplePacketCreator.spawnPlayerMapobject(this)); 
            } 
        } 

      [
    MENTION=2000004426]Override[/MENTION
        public 
    void setObjectId(int id) { 
        } 

      [
    MENTION=2000004426]Override[/MENTION
        public 
    String toString() { 
            return 
    name
        } 

        private 
    int givenRiceCakes
        private 
    boolean gottenRiceHat

        public 
    int getGivenRiceCakes() { 
            return 
    givenRiceCakes
        } 

        public 
    void increaseGivenRiceCakes(int amount) { 
            
    this.givenRiceCakes += amount
        } 

        public 
    boolean getGottenRiceHat() { 
            return 
    gottenRiceHat
        } 

        public 
    void setGottenRiceHat(boolean b) { 
            
    this.gottenRiceHat b
        } 

        public 
    int getLinkedLevel() { 
            return 
    linkedLevel
        } 

        public 
    String getLinkedName() { 
            return 
    linkedName
        } 

        public 
    CashShop getCashShop() { 
            return 
    cashshop
        } 

        public 
    void portalDelay(long delay) { 
            
    this.portaldelay System.currentTimeMillis() + delay
        } 

        public 
    long portalDelay() { 
            return 
    portaldelay
        } 

        public 
    void blockPortal(String scriptName) { 
            if (!
    blockedPortals.contains(scriptName) && scriptName != null) { 
                
    blockedPortals.add(scriptName); 
                
    client.announce(MaplePacketCreator.enableActions()); 
            } 
        } 

        public 
    void unblockPortal(String scriptName) { 
            if (
    blockedPortals.contains(scriptName) && scriptName != null) { 
                
    blockedPortals.remove(scriptName); 
            } 
        } 

        public List<
    StringgetBlockedPortals() { 
            return 
    blockedPortals
        } 

        public 
    boolean containsAreaInfo(int areaString info) { 
            
    Short area_ Short.valueOf((shortarea); 
            if (
    area_info.containsKey(area_)) { 
                return 
    area_info.get(area_).contains(info); 
            } 
            return 
    false
        } 

        public 
    void updateAreaInfo(int areaString info) { 
            
    area_info.put(Short.valueOf((shortarea), info); 
            
    announce(MaplePacketCreator.updateAreaInfo(areainfo)); 
        } 

        public 
    String getAreaInfo(int area) { 
            return 
    area_info.get(Short.valueOf((shortarea)); 
        } 

        public 
    Map<ShortStringgetAreaInfos() { 
            return 
    area_info
        } 

        public 
    void autoban(String reasonint greason) { 
            
    Calendar cal Calendar.getInstance(); 
            
    cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE)); 
            
    Timestamp TS = new Timestamp(cal.getTimeInMillis()); 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE accounts SET banreason = ?, tempban = ?, greason = ? WHERE id = ?")) { 
                    
    ps.setString(1reason); 
                    
    ps.setTimestamp(2TS); 
                    
    ps.setInt(3greason); 
                    
    ps.setInt(4accountid); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
            } 
        } 

        public 
    void block(int reasonint daysString desc) { 
            
    Calendar cal Calendar.getInstance(); 
            
    cal.add(Calendar.DATEdays); 
            
    Timestamp TS = new Timestamp(cal.getTimeInMillis()); 
            try { 
                
    Connection con DatabaseConnection.getConnection(); 
                try (
    PreparedStatement ps con.prepareStatement("UPDATE accounts SET banreason = ?, tempban = ?, greason = ? WHERE id = ?")) { 
                    
    ps.setString(1desc); 
                    
    ps.setTimestamp(2TS); 
                    
    ps.setInt(3reason); 
                    
    ps.setInt(4accountid); 
                    
    ps.executeUpdate(); 
                } 
            } catch (
    SQLException e) { 
            } 
        } 

        public 
    boolean isBanned() { 
            return 
    isbanned
        } 

        public 
    int[] getTrockMaps() { 
            return 
    trockmaps
        } 

        public 
    int[] getVipTrockMaps() { 
            return 
    viptrockmaps
        } 

        public 
    int getTrockSize() { 
            
    int ret 0
            for (
    int i 05i++) { 
                if (
    trockmaps[i] != 999999999) { 
                    
    ret++; 
                } 
            } 
            return 
    ret
        } 

        public 
    void deleteFromTrocks(int map) { 
            for (
    int i 05i++) { 
                if (
    trockmaps[i] == map) { 
                    
    trockmaps[i] = 999999999
                    break; 
                } 
            } 
        } 

        public 
    void addTrockMap() { 
            if (
    getTrockSize() >= 5) { 
                return; 
            } 
            
    trockmaps[getTrockSize()] = getMapId(); 
        } 

        public 
    boolean isTrockMap(int id) { 
            for (
    int i 05i++) { 
                if (
    trockmaps[i] == id) { 
                    return 
    true
                } 
            } 
            return 
    false
        } 

        public 
    int getVipTrockSize() { 
            
    int ret 0
            for (
    int i 010i++) { 
                if (
    viptrockmaps[i] != 999999999) { 
                    
    ret++; 
                } 
            } 
            return 
    ret
        } 

        public 
    void deleteFromVipTrocks(int map) { 
            for (
    int i 010i++) { 
                if (
    viptrockmaps[i] == map) { 
                    
    viptrockmaps[i] = 999999999
                    break; 
                } 
            } 
        } 

        public 
    void addVipTrockMap() { 
            if (
    getVipTrockSize() >= 10) { 
                return; 
            } 

            
    viptrockmaps[getVipTrockSize()] = getMapId(); 
        } 

        public 
    boolean isVipTrockMap(int id) { 
            for (
    int i 010i++) { 
                if (
    viptrockmaps[i] == id) { 
                    return 
    true
                } 
            } 
            return 
    false
        } 

        
    // EVENTS 
        
    private byte team 0
        private 
    MapleFitness fitness
        private 
    MapleOla ola
        private 
    long snowballattack

        public 
    byte getTeam() { 
            return 
    team
        } 

        public 
    void setTeam(int team) { 
            
    this.team = (byteteam
        } 

        public 
    MapleOla getOla() { 
            return 
    ola
        } 

        public 
    void setOla(MapleOla ola) { 
            
    this.ola ola
        } 

        public 
    MapleFitness getFitness() { 
            return 
    fitness
        } 

        public 
    void setFitness(MapleFitness fit) { 
            
    this.fitness fit
        } 

        public 
    long getLastSnowballAttack() { 
            return 
    snowballattack
        } 

        public 
    void setLastSnowballAttack(long time) { 
            
    this.snowballattack time
        } 

        
    // Monster Carnival 
        
    private int cp 0
        private 
    int obtainedcp 0
        private 
    MonsterCarnivalParty carnivalparty
        private 
    MonsterCarnival carnival

        public 
    MonsterCarnivalParty getCarnivalParty() { 
            return 
    carnivalparty
        } 

        public 
    void setCarnivalParty(MonsterCarnivalParty party) { 
            
    this.carnivalparty party
        } 

        public 
    MonsterCarnival getCarnival() { 
            return 
    carnival
        } 

        public 
    void setCarnival(MonsterCarnival car) { 
            
    this.carnival car
        } 

        public 
    int getCP() { 
            return 
    cp
        } 

        public 
    int getObtainedCP() { 
            return 
    obtainedcp
        } 

        public 
    void addCP(int cp) { 
            
    this.cp += cp
            
    this.obtainedcp += cp
        } 

        public 
    void useCP(int cp) { 
            
    this.cp -= cp
        } 

        public 
    void setObtainedCP(int cp) { 
            
    this.obtainedcp cp
        } 

        public 
    int getAndRemoveCP() { 
            
    int rCP 10
            if (
    cp 9) { 
                
    rCP cp
                
    cp 0
            } else { 
                
    cp -= 10
            } 

            return 
    rCP
        } 

        public 
    AutobanManager getAutobanManager() { 
            return 
    autoban
        } 

        public 
    void equipPendantOfSpirit() { 
            if (
    pendantOfSpirit == null) { 
                
    pendantOfSpirit TimerManager.getInstance().register(new Runnable() { 
                  [
    MENTION=2000004426]Override[/MENTION
                    public 
    void run() { 
                        if (
    pendantExp 3) { 
                            
    pendantExp++; 
                            
    message("Pendant of the Spirit has been equipped for " pendantExp " hour(s), you will now receive " pendantExp "0% bonus exp."); 
                        } else { 
                            
    pendantOfSpirit.cancel(false); 
                        } 
                    } 
                }, 
    3600000); // 1 hour 
            

        } 

        public 
    void unequipPendantOfSpirit() { 
            if (
    pendantOfSpirit != null) { 
                
    pendantOfSpirit.cancel(false); 
                
    pendantOfSpirit null
            } 
            
    pendantExp 0
        } 

        public 
    void increaseEquipExp(int mobexp) { 
            
    MapleItemInformationProvider mii MapleItemInformationProvider.getInstance(); 
            for (
    Item item getInventory(MapleInventoryType.EQUIPPED).list()) { 
                
    Equip nEquip = (Equipitem
                
    String itemName mii.getName(nEquip.getItemId()); 
                if (
    itemName == null) { 
                    continue; 
                } 

                if ((
    itemName.contains("Reverse") && nEquip.getItemLevel() < 4) || itemName.contains("Timeless") && nEquip.getItemLevel() < 6) { 
                    
    nEquip.gainItemExp(clientmobexpitemName.contains("Timeless")); 
                } 
            } 
        } 

        public 
    Map<StringMapleEventsgetEvents() { 
            return 
    events
        } 

        public 
    PartyQuest getPartyQuest() { 
            return 
    partyQuest
        } 

        public 
    void setPartyQuest(PartyQuest pq) { 
            
    this.partyQuest pq
        } 

        public final 
    void empty(final boolean remove) {// lol serious shit here 
            
    if (dragonBloodSchedule != null) { 
                
    dragonBloodSchedule.cancel(false); 
            } 
            if (
    hpDecreaseTask != null) { 
                
    hpDecreaseTask.cancel(false); 
            } 
            if (
    beholderHealingSchedule != null) { 
                
    beholderHealingSchedule.cancel(false); 
            } 
            if (
    beholderBuffSchedule != null) { 
                
    beholderBuffSchedule.cancel(false); 
            } 
            if (
    BerserkSchedule != null) { 
                
    BerserkSchedule.cancel(false); 
            } 
            if (
    recoveryTask != null) { 
                
    recoveryTask.cancel(false); 
            } 
            
    cancelExpirationTask(); 
            for (
    ScheduledFuture<?> sf : timers) { 
                sf.cancel(false); 
            } 
            timers.clear(); 
            if (maplemount != null) { 
                maplemount.empty(); 
                maplemount = null; 
            } 
            if (remove) { 
                partyQuest = null; 
                events = null; 
                mpc = null; 
                mgc = null; 
                events = null; 
                party = null; 
                family = null; 
                client = null; 
                map = null; 
                timers = null; 
            } 
        } 

        public void logOff() { 
            this.loggedIn = false; 
        } 

        public boolean isLoggedin() { 
            return loggedIn; 
        } 

        public void setMapId(int mapid) { 
            this.mapid = mapid; 
        } 

        public void doReborn(int job) { 
            final int base = 10; 
            this.reborns++; 
            this.job = MapleJob.getById(job); 
            this.exp.set(0); 
            this.level = base; 
            this.setRemainingAp(getRemainingAp() + (base * 5)); 
            List<Pair<MapleStat, Integer>> statups = new ArrayList<>(); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.JOB, this.job.jobid)); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.LEVEL, getLevel())); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.EXP, exp.get())); 
            statups.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, getRemainingAp())); 
            announce(MaplePacketCreator.updatePlayerStats(statups)); 
            dropMessage("You now have a grand total of " + reborns + " reborns."); 

            String hisher = "his"; 
            if (gender == 1) 
                hisher = "her"; 

            String hesheit = "he"; 
            if (gender == 1) 
                hesheit = "she"; 
            // TODO: put milestones into somewhere concise 
            switch (reborns) { 
                case 1: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 1st reborn! Well done!")); 
                    break; 
                case 10: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 10th reborn!")); 
                    break; 
                case 25: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 25th reborn!")); 
                    break; 
                case 50: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 50th reborn!")); 
                    break; 
                case 100: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 100th reborn, truly remarkable!")); 
                    break; 
                case 1000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on " + hisher + " 1000th reborn, an amazing feat!")); 
                    break; 
                case 5000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "Everybody congratulate " + name + " on hitting the " + hisher + " 5000th! Just when does it stops?")); 
                    break; 
                case 50000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "The player '" + name + "' has just hit " + hisher + " 50000th reborn. How morbedly obese " + hesheit + " is has yet to be found.")); 
                    break; 
                case 100000: 
                    Server.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0, "The player '" + name + " has been found dead lying in a pile of mcdonald Double Quarter Pounder wrappers after having a heart attack. Congratulation on " + hisher + " 100,000th reborn! You may have just won the game.")); 
                    break; 
            } 
        } 

        public long[] getTimestampBuffer() { 
            return timestampBuffer; 
        } 

        public void setTimestamp(int id, long time) { 
            this.timestampBuffer[id] = time; 
        } 

        public long getTimestamp(int id) { 
            return this.timestampBuffer[id]; 
        } 

        // 0,1,2,3 used 
        public boolean matchTimestamp(int duration, int id) { 
            if (id < 0) { 
                throw new InvalidParameterException("Id must be positive!"); 
            } 
            if (duration < 0) { 
                duration = 0; 
            } 

            long elapsed = System.currentTimeMillis() - timestampBuffer[id]; 

            if (elapsed < duration) { 
                return true; 
            } 

            timestampBuffer[id] = System.currentTimeMillis(); 
            return false; 
        } 

        public void setReborn(int reborns) { 
            this.reborns = reborns; 
        } 

        public int getReborns() { 
            return reborns; 
        } 

        public Channel getChannel() { 
            return client.getChannelServer(); 
        } 

        public void addJumpPoints(int i) { 
            this.jumppoints += i; 
        } 

        public void setJumpPoints(int i) { 
            this.jumppoints = i; 
        } 

        public int getJumpPoints() { 
            return jumppoints; 
        } 

        public void fakeRelog() { 
            announce(MaplePacketCreator.getCharInfo(this)); 
            changeMap(map, map.getPortal(map.findClosestSpawnpoint(getPosition()).getId())); 
        } 

        public int getEventPoints() { 
            return eventpoints; 
        } 

        public void setEventPoints(int eventpoints) { 
            this.eventpoints = eventpoints; 
        } 

        public int getVotePoints() { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?"); 
                ps.setInt(1, getAccountID()); 
                ResultSet rs = ps.executeQuery(); 
                rs.next(); 
                int val = rs.getInt("votepoints"); 
                rs.close(); 
                ps.close(); 
                return val; 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            return -1; 
        } 

        public void gainVotePoints(int i) { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET votepoints = ? WHERE id = ?"); 
                ps.setInt(1, getVotePoints() + i); 
                ps.setInt(2, getAccountID()); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        public int getDonorPoints() { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?"); 
                ps.setInt(1, getAccountID()); 
                ResultSet rs = ps.executeQuery(); 
                rs.next(); 
                int val = rs.getInt("donorpoints"); 
                rs.close(); 
                ps.close(); 
                return val; 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            return -1; 
        } 

        public int getTotalDonorPoints() { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?"); 
                ps.setInt(1, getAccountID()); 
                ResultSet rs = ps.executeQuery(); 
                rs.next(); 
                int val = rs.getInt("totaldonorpoints"); 
                rs.close(); 
                ps.close(); 
                return val; 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            return -1; 
        } 

        public void gainDonorPoints(int i) { 
            Connection con = DatabaseConnection.getConnection(); 

            try { 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET donorpoints = ?, totaldonorpoints = ? WHERE id = ?"); 
                ps.setInt(1, getDonorPoints() + i); 
                ps.setInt(2, getTotalDonorPoints() + i); 
                ps.setInt(3, getAccountID()); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        public void changeChannel(int channel) { 
            Server server = Server.getInstance(); 
            if (isBanned()) { 
                getClient().disconnect(false, false); 
                return; 
            } 
            if (!isAlive() || FieldLimit.CHANGECHANNEL.check(getMap().getFieldLimit())) { 
                getClient().announce(MaplePacketCreator.enableActions()); 
                return; 
            } 
            String[] socket = Server.getInstance().getIP(getClient().getWorld(), channel).split(":"); 
            if (getTrade() != null) { 
                MapleTrade.cancelTrade(getClient().getPlayer()); 
            } 

            HiredMerchant merchant = getHiredMerchant(); 
            if (merchant != null) { 
                if (merchant.isOwner(getClient().getPlayer())) { 
                    merchant.setOpen(true); 
                } else { 
                    merchant.removeVisitor(getClient().getPlayer()); 
                } 
            } 
            server.getPlayerBuffStorage().addBuffsToStorage(getId(), getAllBuffs()); 
            cancelBuffEffects(); 
            cancelMagicDoor(); 
            saveCooldowns(); 

            // Canceling mounts? Noty 
            if (getBuffedValue(MapleBuffStat.PUPPET) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.PUPPET); 
            } 
            if (getBuffedValue(MapleBuffStat.COMBO) != null) { 
                cancelEffectFromBuffStat(MapleBuffStat.COMBO); 
            } 
            getInventory(MapleInventoryType.EQUIPPED).checked(false); // test 
            getMap().removePlayer(this); 
            getClient().getChannelServer().removePlayer(this); 
            saveToDB(); 
            getClient().updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION); 
            try { 
                getClient().announce(MaplePacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1]))); 
            } catch (IOException e) { 
            } 
        } 

        /* 
         * 1: perm ban 
         * 2: temp ban 
         * 3: hell ban 
         */ 
        public void ban(int type, String banreason, long tempban) { 
            try { 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ?, tempban = ? WHERE id = ?"); 
                ps.setInt(1, type); 
                ps.setString(2, banreason); 
                if (type == 2) 
                    ps.setDate(3, new Date(tempban)); 
                else 
                    ps.setString(3, "0000-00-00 00:00:00"); 
                ps.setInt(4, getAccountID()); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 

            sendPolice(banreason, 3200); 
        } 

        /* 
         * 0: perm ban 
         * 1: temp ban 
         * 2: hell ban 
         */ 
        public static void ban(String name, int type, String banreason, long tempban) { 
            try { 
                Connection con = DatabaseConnection.getConnection(); 
                PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ?, tempban = ? WHERE id = ?"); 
                ps.setInt(1, type); 
                ps.setString(2, banreason); 
                if (type == 1) 
                    ps.setDate(3, new Date(tempban)); 
                else 
                    ps.setString(3, "0000-00-00 00:00:00"); 
                ps.setInt(4, getAccountIdByCharacterName(name)); 
                ps.executeUpdate(); 
                ps.close(); 
            } catch (SQLException e) { 
                e.printStackTrace(); 
            } 
        } 

        public final Map<CustomQuest, MapleCustomQuestStatus> getCustomQuest_Map() { 
            return customQuests; 
        } 

        public final byte getCustomQuestStatus(final int quest) { 
            final MapleCustomQuestStatus qq = getCustomQuest(CustomQuestProvider.getInstance(quest)); 
            return (qq == null ? 0 : qq.getStatus()); 
        } 

        public final String getCustomQuestData(final int quest) { 
            final MapleCustomQuestStatus qq = getCustomQuest(CustomQuestProvider.getInstance(quest)); 
            if (qq == null) { 
                return ""; 
            } 
            final String info = qq.getCustomData(); 
            return (info == null ? "" : info); 
        } 

        public final MapleCustomQuestStatus getCustomQuest(final CustomQuest quest) { 
            if (quest == null) { 
                return null; 
            } 
            if (!customQuests.containsKey(quest)) { 
                final MapleCustomQuestStatus status = new MapleCustomQuestStatus(quest, (byte) 0); 
                customQuests.put(quest, status); 
                return status; 
            } 
            return customQuests.get(quest); 
        } 

        public final void updateCustomQuest(final MapleCustomQuestStatus quest) { 
            customQuests.put(quest.getQuest(), quest); 
        } 

        public final void setCustomQuestAdd(final CustomQuest quest, final byte status, final String customData) { 
            if (!customQuests.containsKey(quest)) { 
                final MapleCustomQuestStatus stat = new MapleCustomQuestStatus(quest, status); 
                stat.setCustomData(customData); 
                customQuests.put(quest, stat); 
            } 
        } 

        public final void removeCustomQuest(final CustomQuest quest) { 
            if (customQuests.containsKey(quest)) { 
                customQuests.remove(quest); 
            } 
        } 

        public void customMobKilled(final int id, final int skillID) { 
            final StringBuilder sb = new StringBuilder("#bQuest Progress#k\r\n"); 
            for (MapleCustomQuestStatus q : customQuests.values()) { 
                if (q.getStatus() != 1 || !q.hasMobKills()) { 
                    continue; 
                } 
                if (q.mobKilled(id, skillID)) { 
                    sb.append(MapleLifeFactory.getMonster(id).getStats().getName()).append(" #r").append(q.getMobKills(id)).append(" #k/ ").append(q.maxMob(id)).append("\r\n"); 
                    if (q.getQuest().canComplete(this, null)) { 
                        client.getSession().write(MaplePacketCreator.getShowQuestCompletion(1)); // If its 0, then show "New Quest!" 
                    } 
                } 
            } 
            if (sb.indexOf("/") != -1) { 
                client.getSession().write(MaplePacketCreator.sendHint(sb.toString(), 220, 1)); // Ignore height 
            } 
        } 

        public void checkQuestDrops(final int itemId) { 
            final StringBuilder sb = new StringBuilder("#bQuest Progress#k\r\n"); 
            for (MapleCustomQuestStatus q : customQuests.values()) { 
                if (q.getStatus() != 1 || q.getQuest().getReqItems() == null) { 
                    continue; 
                } 
                for (final Entry<Integer, Integer> qa : q.getQuest().getReqItems().entrySet()) { 
                    if (qa.getKey() == itemId) { 
                        if (getItemQuantity(itemId, true) > qa.getValue()) { 
                            continue; 
                        } 
                        sb.append(MapleItemInformationProvider.getInstance().getName(itemId)).append(" #r").append(getItemQuantity(itemId, true)).append(" #k/ ").append(qa.getValue()).append("\r\n"); 
                        if (q.getQuest().canComplete(this, null)) { 
                            client.getSession().write(MaplePacketCreator.getShowQuestCompletion(1)); // If its 0, then show "New Quest!" 
                        } 
                    } 
                } 
            } 
            if (sb.indexOf("/") != -1) { 
                client.getSession().write(MaplePacketCreator.sendHint(sb.toString(), 220, 1)); // Ignore height 
            } 
        } 

        public void talk(String string) { 
            getMap().broadcastMessage(MaplePacketCreator.getChatText(getId(), string, gmLevel() > 3 ? whitechatgm : false, 0)); 
        } 

        public void addTracker(MapleCharacter tracker) { 
            trackers.add(tracker); 
        } 

        public void removeTracker(int cid) { 
            int i = 0; 
            boolean ff = false; 
            for (MapleCharacter track : trackers) { 
                if (track.getId() == cid) { 
                    ff = true; 
                    break; 
                } 
                i++; 
            } 
            if (ff) { 
                trackers.remove(i); 
            } 
        } 

        public List<MapleCharacter> getAllTrackers() { 
            return trackers; 
        } 

        public void notifyTrackers() { 
            for (MapleCharacter track : trackers) { 
                track.dropMessage(5, "Your tracked victim '" + getName() + "' has moved to " + getMap().getMapName() + " in channel " + getClient().getChannel()); 
            } 
        } 

        public void dropItems(int i) { 
            dropItems(i, Randomizer.next(10, 20)); 
        } 

        public void dropItems(int i, int qty) { 
            dropItems(i, qty, 25); 
        } 

        public void dropItems(int i, int qty, int spread) { 
            final int playerpos = getPosition().x; 
            byte d = 1; 
            Point pos = new Point(0, getPosition().y); 

            for (byte b = 0; b < qty; b++) { 
                if (haveItem(i)) { 
                    pos.x = (int) (playerpos + ((d % 2 == 0) ? (spread * (d + 1) / 2) : -(spread * (d / 2)))); 
                    MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(i); 
                    MapleInventoryManipulator.removeById(getClient(), type, i, 1, false, false); 
                    map.spawnItemDrop(this, this, new Item(i, (byte) 0, (short) 1), map.calcDropPos(pos, getPosition()), true, true); 
                    d++; 
                } else { 
                    break; 
                } 
            } 
        } 

        public int tryExecutePower(int id) { 
            return tryExecutePower(id, null, false); 
        } 

        public int tryExecutePower(int id, boolean print) { 
            return tryExecutePower(id, null, print); 
        } 

        public int tryExecutePower(int id, String[] splitted, boolean print) { 
            OccupationFactory factory = OccupationFactory.getInstance(); 
            if (getOccupation() != null) { 
                for (OccupationInfo info : factory.getAllOccupations()) { 
                    if (info.getId() == getOccupation().getInfo().getId()) { 
                        for (Pair<Integer, OccupationPower> power : info.powers) { 
                            if (power.getRight().getId() == id) { 
                                if (power.getLeft() <= getOccupation().getLevel()) { 
                                    return power.getRight().execute(getClient(), splitted != null, splitted); 
                                } else { 
                                    if (print) 
                                        dropMessage(5, "Your occupation level does not match the required level for this power. (required: " + power.getLeft() + ")"); 
                                    return 1; 
                                } 
                            } 
                        } 
                    } 
                } 
            } else { 
                return -3; // No occupation ! 
            } 
            if (print) 
                dropMessage(5, "It seems like you do not have access to this power"); 
            return -1; // power not found! dohhh! 
        } 

        public void gainOccupationExp(int amount) { 
            getOccupation().gainExp(amount); 
        } 

        public OccupationEntry getOccupation() { 
            return occupation; 
        } 

        public void changeOccupation(int id, int level, int exp) { 
            if (id == -1) 
                occupation = null; 
            else { 
                if (id == 0) 
                    pollHeneHoe(true); 
                occupation = OccupationEntry.generateEntry(this, id, level, exp); 
                getMap().broadcastMessage(this, MaplePacketCreator.showForeignEffect(getId(), 8), true); 
            } 
        } 

        public void changeOccupation(int id, int level) { 
            changeOccupation(id, level, 0); 
        } 

        public void undressAll() { 
            List<Item> itemMap = new LinkedList<>(); 
            for (Item item : getInventory(MapleInventoryType.EQUIPPED).list()) { 
                itemMap.add((Item) item); 
            } 
            for (Item item : itemMap) { 
                if (!getInventory(MapleInventoryType.EQUIP).isFull()) { 
                    MapleInventoryManipulator.unequip(getClient(), item.getPosition(), getInventory(MapleInventoryType.EQUIP).getNextFreeSlot()); 
                } 
            } 
        } 

        public void die() { 
            setHp(0); 
            updateSingleStat(MapleStat.HP, 0); 
        } 

        public void gainOccuExp(int j) { 
            int i = j - 2; 
            if (i < 1) 
                i = 1; 
            MapleInventoryManipulator.addById(client, 4032061, (short) Randomizer.next(i, j)); 
            occupation.gainExp(j); 
        } 

        public void pollHeneHoe(boolean initialize) { 
            if (getMapId() == 100000000 || getMapId() == 910000000) { // still in henesys ? 
                if (!initialize) { 
                    int delta = Randomizer.next(2, 5); 
                    gainOccuExp(delta); 
                    dropMessage(-1, "You have gained " + delta + " occupation EXP for staying in henesys !"); 
                } 
                TimerManager.getInstance().schedule(new Runnable() { 
                    public void run() { 
                        pollHeneHoe(false); 
                    } 
                }, 1000 * 60 * Randomizer.next(2, 4)); 
            } 
            TimerManager.getInstance().purge(); 
        } 

    }

  13. #13
    desk.getCoffee().drink(); AngelSpirit is offline
    MemberRank
    Jul 2010 Join Date
    CanadaLocation
    318Posts

    Re: SaveToDB Problem

    I'm of the firm opinion that you should be having nothing to do with a server without at least knowing what technologies and libraries the codebase is using, but that's beside the point. You should at least know something before going in.

    Quote Originally Posted by ooSnowCapxx
    There is no query that I'm trying to execute...lol.
    Quote Originally Posted by ooSnowCapxx
    Also, this isn't the same problem as my last thread whereas this one is 'WHERE id = 5' not 'WHERE id = 1'
    I mean, come on.

    Please, learn some more before you make your next help thread. If I see another SQL error post I'm not even going to bother.
    Code:
     ps = con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, gachaexp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpMpUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, mountlevel = ?, mountexp = ?, mounttiredness= ?, equipslots = ?, useslots = ?, setupslots = ?, etcslots = ?,  monsterbookcover = ?, vanquisherStage = ?, dojoPoints = ?, lastDojoStage = ?, finishedDojoTutorial = ?, vanquisherKills = ?, matchcardwins = ?, matchcardlosses = ?, matchcardties = ?, omokwins = ?, omoklosses = ?, omokties = ?, reborns = ?, name = ?, jumppoints = ?, jailed = ?, jailtime = ?, jailduration = ?, eventpoints = ?, occuid = ?, occulevel = ?, occuexp = ?, legend = ?, horntail_slyed = ?, pinkbeen_slyed = ?, WHERE id = ?", Statement.RETURN_GENERATED_KEYS);
    This is the query it's running. Find out what syntax is misplaced.



Advertisement