Java script pataisymas

    
  1. Atsijungęs

    Harden

    Pranešimai: 0

    štai kodas:

    /*
     * Copyright (C) 2004-2013 L2J DataPack
     *
     * This file is part of L2J DataPack.
     *
     * L2J DataPack is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * L2J DataPack 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
     * General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program. If not, see <http://www.gnu.org/licenses/>.
     */
    package custom.Services;
     
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.util.logging.Logger;
    
    import net.sf.l2j.L2DatabaseFactory;
    import net.sf.l2j.gameserver.datatables.CharNameTable;
    import net.sf.l2j.gameserver.datatables.ClanTable;
    import net.sf.l2j.gameserver.model.actor.L2Npc;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
    import net.sf.l2j.gameserver.model.quest.Quest;
    import net.sf.l2j.gameserver.model.quest.QuestState;
    import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
     
    /**
     * @author Colet
     * Interlude rework SweeTs
     */
    public class Services extends Quest
    {
        public static final Logger _log = Logger.getLogger(Services.class.getName());
       
        // NPC Id
        int servicesNpc = 50008;
       
        // Noble Items
        int nobleItemId = 57;
        int nobleItemCount = 1000000;
       
        // PK Reduce Items
        int pkReduceItemId = 57;
        int pkReduceItemCount = 1000;
       
        // Change Name Items
        int changeNameItemId = 57;
        int changeNameItemCount = 1000000;
        boolean logNameChanges = true;
       
        // Change Clan Name Items
        int changeClanNameItemId = 57;
        long changeClanNameItemCount = 50000;
        boolean logClanNameChanges = true;
        int clanMinLevel = 5;
        
        // Clan Level Items
        int[] clanLevelItemsId =
        {
        	57, // Level 5 to 6
        	57, // Level 6 to 7
        	57, // Level 7 to 8
        };
        
        int[] clanLevelItemsCount =
        {
        	6, // Level 5 to 6
        	7, // Level 6 to 7
        	8, // Level 7 to 8
        };
        
        // Clan Reputation Points Items
        int clanReputationPointsItemId = 57;
        int clanReputationPointsItemCount = 1;
        
        // Change Gender Items
        int changeGenderItemId = 57;
        int changeGenderItemCount = 50;
        
        public Services(int questId, String name, String descr)
        {
            super(questId, name, descr);
           
            addStartNpc(servicesNpc);
            addFirstTalkId(servicesNpc);
            addTalkId(servicesNpc);
        }
       
        public static void main(String[] args)
        {
            new Services(-1, Services.class.getSimpleName(), "custom");
        }
       
        @Override
        public String onFirstTalk(L2Npc npc, L2PcInstance player)
        {
            if (player.getQuestState(getName()) == null)
            {
                newQuestState(player);
            }
            else if (player.isInCombat())
            	return "Services-Blocked.htm";
            
            else if (player.getPvpFlag() == 1)
            	return "Services-Blocked.htm";
            
            else if (player.getKarma() != 0)
            	return "Services-Blocked.htm";
            
            else if (OlympiadManager.getInstance().isRegistered(player))
            	return "Services-Blocked.htm";
            
            else if (player.isDead() || player.isFakeDeath())
            	return "Services-Blocked.htm";
            
            return "Services.htm";
        }
       
        @Override
        public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
        {
            String htmlText = event;
            QuestState st = player.getQuestState(getName());
           
            if (event.equals("setNoble"))
            {
                if (!player.isNoble())
                {
                    if (st.getQuestItemsCount(nobleItemId) >= nobleItemCount)
                    {
                        st.takeItems(nobleItemId, nobleItemCount);
                        player.setNoble(true,true);
                        player.setTarget(player);
                        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                        player.broadcastUserInfo();
                        return "NoblesseServices-Success.htm";
                    }
    				return "NoblesseServices-NoItems.htm";
                }
    			return "NoblesseServices-AlredyNoble.htm";
            }
            else if (event.equals("levelUpClan"))
            {
            	if (player.getClan() == null)
                {
                	return "ClanLevelUp-NoClan.htm";
                }
            	else if (!player.isClanLeader())
            	{
            		return "ClanLevelUp-NoLeader.htm";
            	}
            	else
            	{
            		if (player.getClan().getLevel() == 8)
            		{
            			return "ClanLevelUp-MaxLevel.htm";
            		}
    				if (((player.getClan().getLevel() <= 1) || (player.getClan().getLevel() == 2) || (player.getClan().getLevel() == 3) || (player.getClan().getLevel() == 4)))
    				{
    					player.getClan().setLevel(player.getClan().getLevel() + 1);
    					player.getClan().broadcastClanStatus();
    					player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				    player.setTarget(player);
    				    player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				    return "ClanLevelUp.htm";
    				}
    				else if (player.getClan().getLevel() == 5)
    				{
    					if (st.getQuestItemsCount(clanLevelItemsId[0]) >= clanLevelItemsCount[0])
    					{
    						st.takeItems(clanLevelItemsId[0], clanLevelItemsCount[0]);
    						player.getClan().setLevel(player.getClan().getLevel() + 1);
    						player.getClan().broadcastClanStatus();
    						player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				        player.setTarget(player);
    				        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				        return "ClanLevelUp.htm";
    					}
    					return "ClanLevelUp-NoItems.htm";
    				}
    				else if (player.getClan().getLevel() == 6)
    				{
    					if (st.getQuestItemsCount(clanLevelItemsId[1]) >= clanLevelItemsCount[1])
    					{
    						st.takeItems(clanLevelItemsId[1], clanLevelItemsCount[1]);
    						player.getClan().setLevel(player.getClan().getLevel() + 1);
    						player.getClan().broadcastClanStatus();
    						player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				        player.setTarget(player);
    				        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				        return "ClanLevelUp.htm";
    					}
    					return "ClanLevelUp-NoItems.htm";
    				}
    				else if (player.getClan().getLevel() == 7)
    				{
    					if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2])
    					{
    						st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]);
    						player.getClan().setLevel(player.getClan().getLevel() + 1);
    						player.getClan().broadcastClanStatus();
    						player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				        player.setTarget(player);
    				        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				        return "ClanLevelUp.htm";
    					}
    					return "ClanLevelUp-NoItems.htm";
    				}
    				
    				try (Connection con = L2DatabaseFactory.getInstance().getConnection())
    				{
    					PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_level=? WHERE clan_id=?");
    					statement.setInt(1, player.getClan().getLevel());
    					statement.setInt(2, player.getClan().getClanId());
    					statement.execute();
    					statement.close();
    				}
    				catch (Exception e)
    				{
    					_log.info("Error updating clan level for player " + player.getName() + ". Error: " + e);
    				}
    				
    				player.getClan().broadcastClanStatus();
    				return "ClanLevelUp.htm";
            	}
            }
            else if (event.equals("changeGender"))
            {
            	if (st.getQuestItemsCount(changeGenderItemId) >= changeGenderItemCount)
            	{
                	st.takeItems(changeGenderItemId, changeGenderItemCount);
                	player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
                    player.setTarget(player);
                    player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                	player.broadcastUserInfo();
                	return "ChangeGender-Success.htm";
            	}
    			return "ChangeGender-NoItems.htm";
            }
            else if (event.startsWith("changeName"))
            {
                try
                {
                    String newName = event.substring(11);
                   
                    if (st.getQuestItemsCount(changeNameItemId) >= changeNameItemCount)
                    {                                                      
                        if (newName == null)
                        {                                                      
                            return "ChangeName.htm";
                        }
    					if (!newName.matches("^[a-zA-Z0-9]+$"))
    					{
    					    player.sendMessage("Incorrect name. Please try again.");
    					    return "ChangeName.htm";
    					}
    					else if (newName.equals(player.getName()))
    					{
    					    player.sendMessage("Please, choose a different name.");
    					    return "ChangeName.htm";
    					}
    					else if (CharNameTable.doesCharNameExist(newName))
    					{
    					    player.sendMessage("The name " + newName + " already exists.");
    					    return "ChangeName.htm";
    					}
    					else
    					{
    					    st.takeItems(changeNameItemId, changeNameItemCount);
    					    player.setName(newName);
    					    player.store();
    					    player.sendMessage("Your new character name is " + newName);
    					    player.broadcastUserInfo();
    					    player.getClan().broadcastClanStatus();
    					    return "ChangeName-Success.htm";
    					}
                    }
    				return "ChangeName-NoItems.htm";
                }
                catch (Exception e)
                {
                    player.sendMessage("Please, insert a correct name.");
                    return "ChangeName.htm";
                }
            }
            else if (event.startsWith("reducePks"))
            {
                try
                {
                    String pkReduceString = event.substring(10);
                    int pkReduceCount = Integer.parseInt(pkReduceString);
                    
                    if (player.getPkKills() != 0)
                    {
                        if (pkReduceCount == 0)
                        {
                            player.sendMessage("Please, put a higher value.");
                            return "PkServices.htm";
                        }
    					if (st.getQuestItemsCount(pkReduceItemId) >= pkReduceItemCount)
    					{
    					    st.takeItems(pkReduceItemId, pkReduceItemCount * pkReduceCount);
    					    player.setPkKills(player.getPkKills() - pkReduceCount);
    					    player.sendMessage("You have successfuly cleaned " + pkReduceCount + " PKs.");
    					    player.broadcastUserInfo();
    					    return "PkServices-Success.htm";
    					}
    					return "PkServices-NoItems.htm";
                    }
    				return "PkServices-NoPks.htm";
                }
                catch (Exception e)
                {
                    player.sendMessage("Incorrect value. Please try again.");
                    return "PkServices.htm";
                }
            }
            else if (event.startsWith("changeClanName"))
            {
            	if (player.getClan() == null)
            	{
            		return "ChangeClanName-NoClan.htm";
            	}
    			try
    			{
    				String newClanName = event.substring(15);
    				
    				if (st.getQuestItemsCount(changeClanNameItemId) >= changeClanNameItemCount)
    				{
    					if (newClanName == null)
    					{
    						return "ChangeClanName.htm";
    					}
    					if (!player.isClanLeader())
    					{
    						player.sendMessage("Only the clan leader can change the clan name.");
    						return "ChangeClanName.htm";
    					}
    					else if (player.getClan().getLevel() < clanMinLevel)
    					{
    						player.sendMessage("Your clan must be at least level " + clanMinLevel + " to change the name.");
    						return "ChangeClanName.htm";
    					}
    					else if (!newClanName.matches("^[a-zA-Z0-9]+$"))
    					{
    					    player.sendMessage("Incorrect name. Please try again.");
    					    return "ChangeClanName.htm";
    					}
    					else if (newClanName.equals(player.getClan().getName()))
    					{
    					    player.sendMessage("Please, choose a different name.");
    					    return "ChangeClanName.htm";
    					}
    					else if (ClanTable.getInstance().getClanByName(newClanName) != null)
    					{
    					    player.sendMessage("The name " + newClanName + " already exists.");
    					    return "ChangeClanName.htm";
    					}
    					else
    					{
    					    st.takeItems(changeNameItemId, changeNameItemCount);
    					    player.getClan().setName(newClanName);
    					    
    					    try (Connection con = L2DatabaseFactory.getInstance().getConnection())
    					    {
    					    	PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_name=? WHERE clan_id=?");
    					    	statement.setString(1, newClanName);
    					    	statement.setInt(2, player.getClan().getClanId());
    					    	statement.execute();
    					    	statement.close();
    					    }
    					    catch (Exception e)
    					    {
    					    	_log.info("Error updating clan name for player " + player.getName() + ". Error: " + e);
    					    }
    					    
    					    player.sendMessage("Your new clan name is " + newClanName);
    					    player.getClan().broadcastClanStatus();
    					    return "ChangeClanName-Success.htm";
    					}
    				}
    				return "ChangeClanName-NoItems.htm";
    			}
    			catch (Exception e)
    			{
    			    player.sendMessage("Please, insert a correct name.");
    			    return "ChangeClanName.htm";
    			}
            }
            else if (event.startsWith("setReputationPoints"))
            {
                try
                {
                    String reputationPointsString = event.substring(20);
                    int reputationPointsCount = Integer.parseInt(reputationPointsString);
                    
                    if (player.getClan() == null)
                    {
                    	return "ClanReputationPoints-NoClan.htm";
                    }
                    else if (!player.isClanLeader())
                    {
                    	return "ClanReputationPoints-NoLeader.htm";
                    }
                    else
                    {
    	                if (reputationPointsCount == 0)
    	                {
    	                    player.sendMessage("Please, put a higher value.");
    	                    return "ClanReputationPoints.htm";
    	                }
    					if (st.getQuestItemsCount(clanReputationPointsItemId) >= clanReputationPointsItemCount)
    					{
    						st.takeItems(clanReputationPointsItemId, clanReputationPointsItemCount * reputationPointsCount);
    					    player.getClan().addReputationScore(reputationPointsCount);
    					    player.getClan().broadcastClanStatus();
    					    return "ClanReputationPoints-Success.htm";
    					}
    					return "ClanReputationPoints-NoItems.htm";
                    }
                }
                catch (Exception e)
                {
                    player.sendMessage("Incorrect value. Please try again.");
                    return "ClanReputationPoints.htm";
                }
            }
            
            return htmlText;
    	}
    }


    po serverio restarto klano lygis neišsisaugo, nors ir pakeli 8, bet po restarto lieka vėl 0. kame problemos ? gal galit pataisyt kas ?
    10 Lapkričio 2013 - 21:34 / #1
  2. 
  3. Atsijungęs

    wewewe

    Pavadinimas: L2 žaidėjas

    Narys

    Pranešimai: 727

    Vartotojo apdovanojimai: 16

    Nuuuuuu visuuuuu pirmaaaaaa eini i zaidima, pakeli klano leveli, palieki serveri ijungta,ziurai ar log faile neraso klaidos "Error updating clan level for player TRALIAIA. Error: KAZKAS_BAISAUS.

    Jeigu erroro neraaaaa, iskart atsidarai navicat ar koki kita megstama mysql klienta ir ziurai ar issaugojo pakeitimus i clan_data lentele.

    Nuo to priklausys tolimesni veiksmai.
    10 Lapkričio 2013 - 22:40 / #2
  4. 
  5. Atsijungęs

    Harden

    Pranešimai: 0

    error'o nėra. o navicat'e informacija neatsinaujina, kaip buvo lygis nepakilęs, taip ir yra..
    10 Lapkričio 2013 - 23:01 / #3
  6. 
  7. Atsijungęs

    Grax

    Pranešimai: 0

    I koki packa dedi? Acis?
    11 Lapkričio 2013 - 10:17 / #4
  8. 
  9. Atsijungęs

    Harden

    Pranešimai: 0

    taip, aCis.
    11 Lapkričio 2013 - 13:09 / #5
  10. 
  11. Atsijungęs

    wewewe

    Pavadinimas: L2 žaidėjas

    Narys

    Pranešimai: 727

    Vartotojo apdovanojimai: 16

    Ai nu idemiau paziurejau i koda. Tau kai pakelia klano leveli, metodas iskart grazina kokianors reiksme - zemiau esancio kodo nebevykdo. O ten apacioj butent ir yra issaugomi pakeitimai duomenu bazej. Taip kad perkelk visa ta reikala auksciau, arba keisk klases logika - kad ne iskart returnintu, o tik kodo apacioje.
    11 Lapkričio 2013 - 14:56 / #6
  12. 
  13. Atsijungęs

    Harden

    Pranešimai: 0

    na pabandžiau visą kaip sakei reikalą perkelt aukščiau, bet niekas nepasikeitė. Arba aš nemoku, arba tikrai neveikia. Jokių errorų. Įdomus pastebėjimas tas, kad visa kitą išsaugo, tarkime nobless statusą ar clan rep points po restarto išlieka.
    11 Lapkričio 2013 - 15:59 / #7
  14. 
  15. Atsijungęs

    wewewe

    Pavadinimas: L2 žaidėjas

    Narys

    Pranešimai: 727

    Vartotojo apdovanojimai: 16

    Nobless statusas issisaugo todel, kad pakeitimai irasomi i duomenu baze atjungiant zaideja; isjunginejant serveri; periodiskai kas kazkiek laiko. Del clan rep nezinau. Parodyk dabar koki koda turi.
    11 Lapkričio 2013 - 22:25 / #8
  16. 
  17. Atsijungęs

    Harden

    Pranešimai: 0

    Dėkoju už pagalbą, kaip sakei ten tą kodo dalį, kur įrašo duomenis į database perkėliau aukščiau ir veikia. Anksčiau grybą supjoviau ir ne tą dalį perkėliau kurią reikėjo. :)
    11 Lapkričio 2013 - 22:48 / #9
  18. 
  19. Atsijungęs

    Harden

    Pranešimai: 0

    Nei velnio neveikia pasirodo... Nesuprantu, dabar išsaugo durnai, tarkim 1 lvl neišsaugo, kai užkeliu 2 - išsaugo, 3 vėl neišsaugo, 4 - išsaugo ir t.t.

    /*
     * Copyright (C) 2004-2013 L2J DataPack
     *
     * This file is part of L2J DataPack.
     *
     * L2J DataPack is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * L2J DataPack 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
     * General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program. If not, see <http://www.gnu.org/licenses/>.
     */
    package custom.Services;
     
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.util.logging.Logger;
    
    import net.sf.l2j.L2DatabaseFactory;
    import net.sf.l2j.gameserver.datatables.CharNameTable;
    import net.sf.l2j.gameserver.datatables.ClanTable;
    import net.sf.l2j.gameserver.model.actor.L2Npc;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
    import net.sf.l2j.gameserver.model.quest.Quest;
    import net.sf.l2j.gameserver.model.quest.QuestState;
    import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
     
    /**
     * @author Colet
     * Interlude rework SweeTs
     */
    public class Services extends Quest
    {
        public static final Logger _log = Logger.getLogger(Services.class.getName());
       
        // NPC Id
        int servicesNpc = 50008;
       
        // Noble Items
        int nobleItemId = 57;
        int nobleItemCount = 1000000;
       
        // PK Reduce Items
        int pkReduceItemId = 57;
        int pkReduceItemCount = 1000;
       
        // Change Name Items
        int changeNameItemId = 57;
        int changeNameItemCount = 1000000;
        boolean logNameChanges = true;
       
        // Change Clan Name Items
        int changeClanNameItemId = 57;
        long changeClanNameItemCount = 50000;
        boolean logClanNameChanges = true;
        int clanMinLevel = 5;
        
        // Clan Level Items
        int[] clanLevelItemsId =
        {
        	57, // Level 5 to 6
        	57, // Level 6 to 7
        	57, // Level 7 to 8
        };
        
        int[] clanLevelItemsCount =
        {
        	6, // Level 5 to 6
        	7, // Level 6 to 7
        	8, // Level 7 to 8
        };
        
        // Clan Reputation Points Items
        int clanReputationPointsItemId = 57;
        int clanReputationPointsItemCount = 1;
        
        // Change Gender Items
        int changeGenderItemId = 57;
        int changeGenderItemCount = 50;
        
        public Services(int questId, String name, String descr)
        {
            super(questId, name, descr);
           
            addStartNpc(servicesNpc);
            addFirstTalkId(servicesNpc);
            addTalkId(servicesNpc);
        }
       
        public static void main(String[] args)
        {
            new Services(-1, Services.class.getSimpleName(), "custom");
        }
       
        @Override
        public String onFirstTalk(L2Npc npc, L2PcInstance player)
        {
            if (player.getQuestState(getName()) == null)
            {
                newQuestState(player);
            }
            else if (player.isInCombat())
            	return "Services-Blocked.htm";
            
            else if (player.getPvpFlag() == 1)
            	return "Services-Blocked.htm";
            
            else if (player.getKarma() != 0)
            	return "Services-Blocked.htm";
            
            else if (OlympiadManager.getInstance().isRegistered(player))
            	return "Services-Blocked.htm";
            
            else if (player.isDead() || player.isFakeDeath())
            	return "Services-Blocked.htm";
            
            return "Services.htm";
        }
       
        @Override
        public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
        {
            String htmlText = event;
            QuestState st = player.getQuestState(getName());
           
            if (event.equals("setNoble"))
            {
                if (!player.isNoble())
                {
                    if (st.getQuestItemsCount(nobleItemId) >= nobleItemCount)
                    {
                        st.takeItems(nobleItemId, nobleItemCount);
                        player.setNoble(true,true);
                        player.setTarget(player);
                        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                        player.broadcastUserInfo();
                        return "NoblesseServices-Success.htm";
                    }
    				return "NoblesseServices-NoItems.htm";
                }
    			return "NoblesseServices-AlredyNoble.htm";
            }
            else if (event.equals("levelUpClan"))
            {
            	
    			try (Connection con = L2DatabaseFactory.getInstance().getConnection())
    			{
    				PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_level=? WHERE clan_id=?");
    				statement.setInt(1, player.getClan().getLevel());
    				statement.setInt(2, player.getClan().getClanId());
    				statement.execute();
    				statement.close();
    			}
    			catch (Exception e)
    			{
    				_log.info("Error updating clan level for player " + player.getName() + ". Error: " + e);
    			}
    			
            	if (player.getClan() == null)
                {
                	return "ClanLevelUp-NoClan.htm";
                }
            	else if (!player.isClanLeader())
            	{
            		return "ClanLevelUp-NoLeader.htm";
            	}
            	else
            	{
            		if (player.getClan().getLevel() == 8)
            		{
            			return "ClanLevelUp-MaxLevel.htm";
            		}
    				if (((player.getClan().getLevel() <= 1) || (player.getClan().getLevel() == 2) || (player.getClan().getLevel() == 3) || (player.getClan().getLevel() == 4)))
    				{
    					player.getClan().setLevel(player.getClan().getLevel() + 1);
    					player.getClan().broadcastClanStatus();
    					player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				    player.setTarget(player);
    				    player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				    return "ClanLevelUp.htm";
    				}
    				else if (player.getClan().getLevel() == 5)
    				{
    					if (st.getQuestItemsCount(clanLevelItemsId[0]) >= clanLevelItemsCount[0])
    					{
    						st.takeItems(clanLevelItemsId[0], clanLevelItemsCount[0]);
    						player.getClan().setLevel(player.getClan().getLevel() + 1);
    						player.getClan().broadcastClanStatus();
    						player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				        player.setTarget(player);
    				        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				        return "ClanLevelUp.htm";
    					}
    					return "ClanLevelUp-NoItems.htm";
    				}
    				else if (player.getClan().getLevel() == 6)
    				{
    					if (st.getQuestItemsCount(clanLevelItemsId[1]) >= clanLevelItemsCount[1])
    					{
    						st.takeItems(clanLevelItemsId[1], clanLevelItemsCount[1]);
    						player.getClan().setLevel(player.getClan().getLevel() + 1);
    						player.getClan().broadcastClanStatus();
    						player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				        player.setTarget(player);
    				        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				        return "ClanLevelUp.htm";
    					}
    					return "ClanLevelUp-NoItems.htm";
    				}
    				else if (player.getClan().getLevel() == 7)
    				{
    					if (st.getQuestItemsCount(clanLevelItemsId[2]) >= clanLevelItemsCount[2])
    					{
    						st.takeItems(clanLevelItemsId[2], clanLevelItemsCount[2]);
    						player.getClan().setLevel(player.getClan().getLevel() + 1);
    						player.getClan().broadcastClanStatus();
    						player.sendMessage("Your clan is now level " + player.getClan().getLevel() + ".");
    				        player.setTarget(player);
    				        player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
    				        return "ClanLevelUp.htm";
    					}
    					return "ClanLevelUp-NoItems.htm";
    				}
    				
    				player.getClan().broadcastClanStatus();
    				return "ClanLevelUp.htm";
            	}
            }
            else if (event.equals("changeGender"))
            {
            	if (st.getQuestItemsCount(changeGenderItemId) >= changeGenderItemCount)
            	{
                	st.takeItems(changeGenderItemId, changeGenderItemCount);
                	player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
                    player.setTarget(player);
                    player.broadcastPacket(new MagicSkillUse(player, 5103, 1, 1000, 0));
                	player.broadcastUserInfo();
                	return "ChangeGender-Success.htm";
            	}
    			return "ChangeGender-NoItems.htm";
            }
            else if (event.startsWith("changeName"))
            {
                try
                {
                    String newName = event.substring(11);
                   
                    if (st.getQuestItemsCount(changeNameItemId) >= changeNameItemCount)
                    {                                                      
                        if (newName == null)
                        {                                                      
                            return "ChangeName.htm";
                        }
    					if (!newName.matches("^[a-zA-Z0-9]+$"))
    					{
    					    player.sendMessage("Incorrect name. Please try again.");
    					    return "ChangeName.htm";
    					}
    					else if (newName.equals(player.getName()))
    					{
    					    player.sendMessage("Please, choose a different name.");
    					    return "ChangeName.htm";
    					}
    					else if (CharNameTable.doesCharNameExist(newName))
    					{
    					    player.sendMessage("The name " + newName + " already exists.");
    					    return "ChangeName.htm";
    					}
    					else
    					{
    					    st.takeItems(changeNameItemId, changeNameItemCount);
    					    player.setName(newName);
    					    player.store();
    					    player.sendMessage("Your new character name is " + newName);
    					    player.broadcastUserInfo();
    					    player.getClan().broadcastClanStatus();
    					    return "ChangeName-Success.htm";
    					}
                    }
    				return "ChangeName-NoItems.htm";
                }
                catch (Exception e)
                {
                    player.sendMessage("Please, insert a correct name.");
                    return "ChangeName.htm";
                }
            }
            else if (event.startsWith("reducePks"))
            {
                try
                {
                    String pkReduceString = event.substring(10);
                    int pkReduceCount = Integer.parseInt(pkReduceString);
                    
                    if (player.getPkKills() != 0)
                    {
                        if (pkReduceCount == 0)
                        {
                            player.sendMessage("Please, put a higher value.");
                            return "PkServices.htm";
                        }
    					if (st.getQuestItemsCount(pkReduceItemId) >= pkReduceItemCount)
    					{
    					    st.takeItems(pkReduceItemId, pkReduceItemCount * pkReduceCount);
    					    player.setPkKills(player.getPkKills() - pkReduceCount);
    					    player.sendMessage("You have successfuly cleaned " + pkReduceCount + " PKs.");
    					    player.broadcastUserInfo();
    					    return "PkServices-Success.htm";
    					}
    					return "PkServices-NoItems.htm";
                    }
    				return "PkServices-NoPks.htm";
                }
                catch (Exception e)
                {
                    player.sendMessage("Incorrect value. Please try again.");
                    return "PkServices.htm";
                }
            }
            else if (event.startsWith("changeClanName"))
            {
            	if (player.getClan() == null)
            	{
            		return "ChangeClanName-NoClan.htm";
            	}
    			try
    			{
    				String newClanName = event.substring(15);
    				
    				if (st.getQuestItemsCount(changeClanNameItemId) >= changeClanNameItemCount)
    				{
    					if (newClanName == null)
    					{
    						return "ChangeClanName.htm";
    					}
    					if (!player.isClanLeader())
    					{
    						player.sendMessage("Only the clan leader can change the clan name.");
    						return "ChangeClanName.htm";
    					}
    					else if (player.getClan().getLevel() < clanMinLevel)
    					{
    						player.sendMessage("Your clan must be at least level " + clanMinLevel + " to change the name.");
    						return "ChangeClanName.htm";
    					}
    					else if (!newClanName.matches("^[a-zA-Z0-9]+$"))
    					{
    					    player.sendMessage("Incorrect name. Please try again.");
    					    return "ChangeClanName.htm";
    					}
    					else if (newClanName.equals(player.getClan().getName()))
    					{
    					    player.sendMessage("Please, choose a different name.");
    					    return "ChangeClanName.htm";
    					}
    					else if (ClanTable.getInstance().getClanByName(newClanName) != null)
    					{
    					    player.sendMessage("The name " + newClanName + " already exists.");
    					    return "ChangeClanName.htm";
    					}
    					else
    					{
    					    st.takeItems(changeNameItemId, changeNameItemCount);
    					    player.getClan().setName(newClanName);
    					    
    					    try (Connection con = L2DatabaseFactory.getInstance().getConnection())
    					    {
    					    	PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_name=? WHERE clan_id=?");
    					    	statement.setString(1, newClanName);
    					    	statement.setInt(2, player.getClan().getClanId());
    					    	statement.execute();
    					    	statement.close();
    					    }
    					    catch (Exception e)
    					    {
    					    	_log.info("Error updating clan name for player " + player.getName() + ". Error: " + e);
    					    }
    					    
    					    player.sendMessage("Your new clan name is " + newClanName);
    					    player.getClan().broadcastClanStatus();
    					    return "ChangeClanName-Success.htm";
    					}
    				}
    				return "ChangeClanName-NoItems.htm";
    			}
    			catch (Exception e)
    			{
    			    player.sendMessage("Please, insert a correct name.");
    			    return "ChangeClanName.htm";
    			}
            }
            else if (event.startsWith("setReputationPoints"))
            {
                try
                {
                    String reputationPointsString = event.substring(20);
                    int reputationPointsCount = Integer.parseInt(reputationPointsString);
                    
                    if (player.getClan() == null)
                    {
                    	return "ClanReputationPoints-NoClan.htm";
                    }
                    else if (!player.isClanLeader())
                    {
                    	return "ClanReputationPoints-NoLeader.htm";
                    }
                    else
                    {
    	                if (reputationPointsCount == 0)
    	                {
    	                    player.sendMessage("Please, put a higher value.");
    	                    return "ClanReputationPoints.htm";
    	                }
    					if (st.getQuestItemsCount(clanReputationPointsItemId) >= clanReputationPointsItemCount)
    					{
    						st.takeItems(clanReputationPointsItemId, clanReputationPointsItemCount * reputationPointsCount);
    					    player.getClan().addReputationScore(reputationPointsCount);
    					    player.getClan().broadcastClanStatus();
    					    return "ClanReputationPoints-Success.htm";
    					}
    					return "ClanReputationPoints-NoItems.htm";
                    }
                }
                catch (Exception e)
                {
                    player.sendMessage("Incorrect value. Please try again.");
                    return "ClanReputationPoints.htm";
                }
            }
            
            return htmlText;
    	}
    }
    11 Lapkričio 2013 - 23:38 / #10