EnterWorld.java - Форум администраторов игровых серверов
Форум администраторов игровых серверов StormWall - Защита от DDos атак
Регистрация Мнения Справка Пользователи Календарь Все разделы прочитаны
Вернуться   Форум администраторов игровых серверов > MMO > Lineage II

Lineage II
Дискуссии на тему создания, настройки и обслуживания серверов Lineage 2. При поддержке: Премиум услуги по рекламе

Ответ
Опции темы
Непрочитано 27.08.2010, 15:37   #1
Аватар для krisadr
Пользователь

Автор темы (Топик Стартер) EnterWorld.java


Код:
/*
 * This program 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.
 * 
 * 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
 * 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 com.l2dc.gameserver.network.clientpackets.player;

import static com.l2dc.gameserver.model.actor.L2Character.ZONE_PEACE;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2dc.Config;
import com.l2dc.gameserver.Announcements;
import com.l2dc.gameserver.DisconnectManager;
import com.l2dc.gameserver.GameTimeController;
import com.l2dc.gameserver.GmListTable;
import com.l2dc.gameserver.LoginServerThread;
import com.l2dc.gameserver.SevenSigns;
import com.l2dc.gameserver.TaskPriority;
import com.l2dc.gameserver.cache.HtmCache;
import com.l2dc.gameserver.cache.charnames.CharNameCacheManager;
import com.l2dc.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2dc.gameserver.datatables.AdminCommandAccessRights;
import com.l2dc.gameserver.datatables.GMSkillTable;
import com.l2dc.gameserver.datatables.MapRegionTable;
import com.l2dc.gameserver.datatables.SkillTable;
import com.l2dc.gameserver.instancemanager.CastleManager;
import com.l2dc.gameserver.instancemanager.ClanHallManager;
import com.l2dc.gameserver.instancemanager.CoupleManager;
import com.l2dc.gameserver.instancemanager.CursedWeaponsManager;
import com.l2dc.gameserver.instancemanager.DimensionalRiftManager;
import com.l2dc.gameserver.instancemanager.FortManager;
import com.l2dc.gameserver.instancemanager.FortSiegeManager;
import com.l2dc.gameserver.instancemanager.IPManager;
import com.l2dc.gameserver.instancemanager.InstanceManager;
import com.l2dc.gameserver.instancemanager.MailManager;
import com.l2dc.gameserver.instancemanager.PetitionManager;
import com.l2dc.gameserver.instancemanager.QuestManager;
import com.l2dc.gameserver.instancemanager.SiegeManager;
import com.l2dc.gameserver.instancemanager.TerritoryWarManager;
import com.l2dc.gameserver.model.L2Clan;
import com.l2dc.gameserver.model.L2ItemInstance;
import com.l2dc.gameserver.model.L2Skill;
import com.l2dc.gameserver.model.L2World;
import com.l2dc.gameserver.model.actor.L2Character;
import com.l2dc.gameserver.model.actor.instance.L2ClassMasterInstance;
import com.l2dc.gameserver.model.actor.instance.L2PcInstance;
import com.l2dc.gameserver.model.actor.relations.FriendsListEntry;
import com.l2dc.gameserver.model.entity.ClanHall;
import com.l2dc.gameserver.model.entity.Couple;
import com.l2dc.gameserver.model.entity.Fort;
import com.l2dc.gameserver.model.entity.FortSiege;
import com.l2dc.gameserver.model.entity.Hero;
import com.l2dc.gameserver.model.entity.L2Event;
import com.l2dc.gameserver.model.entity.L2EventRaid;
import com.l2dc.gameserver.model.entity.Siege;
import com.l2dc.gameserver.model.entity.tvt.TvTCustomEvent;
import com.l2dc.gameserver.model.entity.tvt.TvTEvent;
import com.l2dc.gameserver.model.quest.Quest;
import com.l2dc.gameserver.model.quest.QuestState;
import com.l2dc.gameserver.network.SystemMessageId;
import com.l2dc.gameserver.network.SystemMessageId2;
import com.l2dc.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2dc.gameserver.network.communityserver.CommunityServerThread;
import com.l2dc.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2dc.gameserver.network.serverpackets.Die;
import com.l2dc.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2dc.gameserver.network.serverpackets.ExBasicActionList;
import com.l2dc.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2dc.gameserver.network.serverpackets.ExGetBookMarkInfo;
import com.l2dc.gameserver.network.serverpackets.ExNoticePostArrived;
import com.l2dc.gameserver.network.serverpackets.ExNotifyBirthDay;
import com.l2dc.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2dc.gameserver.network.serverpackets.ExStorageMaxCount;
import com.l2dc.gameserver.network.serverpackets.HennaInfo;
import com.l2dc.gameserver.network.serverpackets.InventoryUpdate;
import com.l2dc.gameserver.network.serverpackets.ItemList;
import com.l2dc.gameserver.network.serverpackets.L2FriendList;
import com.l2dc.gameserver.network.serverpackets.L2FriendStatus;
import com.l2dc.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2dc.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2dc.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import com.l2dc.gameserver.network.serverpackets.PledgeSkillList;
import com.l2dc.gameserver.network.serverpackets.PledgeStatusChanged;
import com.l2dc.gameserver.network.serverpackets.QuestList;
import com.l2dc.gameserver.network.serverpackets.ShortCutInit;
import com.l2dc.gameserver.network.serverpackets.SkillCoolTime;
import com.l2dc.gameserver.network.serverpackets.SystemMessage;
import com.l2dc.gameserver.network.serverpackets.UserInfo;
import com.l2dc.util.StringUtil;
import com.l2dc.util.EventData.L2EventType;

/**
 * Enter World Packet Handler
 * <p>
 * 0000: 03 <p>
 * packet format rev87 bddddbdcccccccccccccccccccc
 * <p>
 */
public class EnterWorld extends L2GameClientPacket
{
	private static final String _C__03_ENTERWORLD = "[C] 03 EnterWorld";
	
	private static final Logger _log = Logger.getLogger(EnterWorld.class.getName());
	private static final Logger _logAccount = Logger.getLogger("account");
	
	private String _userHost;
	private String _routeHop1;
	private String _routeHop2;
	private String _routeHop3;
	private String _routeHop4;

	public TaskPriority getPriority()
	{
		return TaskPriority.PR_URGENT;
	}
	
	@Override
	protected void readImpl()
	{
		readB(new byte[32]);	// Unknown Byte Array
		readD();				// Unknown Value
		readD();				// Unknown Value
		readD();				// Unknown Value
		readD();				// Unknown Value
		readB(new byte[32]);	// Unknown Byte Array
		readD();				// Unknown Value
		_userHost  = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop1 = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop2 = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop3 = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop4 = readC()+"."+readC()+"."+readC()+"."+readC();
	}
	
	@Override
	protected void runImpl()
	{
		L2PcInstance activeChar = getClient().getActiveChar();
		
		if (activeChar == null)
		{
			_log.warning("EnterWorld failed! activeChar returned 'null'.");
			getClient().closeNow();
			return;
		}
		
		if (_logAccount.isLoggable(Level.INFO))
		{
			_logAccount.info(getClient().toString());
		}
		
		final boolean dontProtect = DisconnectManager.getInstance().removeTimer(activeChar.getObjectId());

		LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(),
				_userHost, _routeHop1, _routeHop2, _routeHop3, _routeHop4);
		
		// Multibox Protection Engine
		if (Config.MULTIBOX_PROTECTION_ENABLED)
			IPManager.getInstance().multiboxKickTask(activeChar, _userHost);
		
		// Restore to instanced area if enabled
		if (Config.RESTORE_PLAYER_INSTANCE)
			activeChar.setInstanceId(InstanceManager.getInstance().getPlayerInstance(activeChar.getObjectId()));
		else
		{
			int instanceId = InstanceManager.getInstance().getPlayerInstance(activeChar.getObjectId());
			if (instanceId > 0)
				InstanceManager.getInstance().getInstance(instanceId).removePlayer(activeChar.getObjectId());
		}
		
		if (activeChar.getPet() != null)
			activeChar.getPet().setInstanceId(activeChar.getInstanceId());
		
		// Restore Vitality
		if (Config.RECOVER_VITALITY_ON_RECONNECT || Config.ENABLE_VITALITY)
			activeChar.getVitalityManagement().restoreVitality();
		
		if (L2World.getInstance().getPlayer(activeChar.getObjectId()) != null)
		{
			if (_log.isLoggable(Level.WARNING))
			{
				_log.warning(StringUtil.concat("User already exists in Object ID map! User ", activeChar.getName(), " is a character clone."));
			}
		}
		// Set the Client IP property
		activeChar.setClientIP();
		
		// Apply special GM properties to the GM when entering
		if (activeChar.isGM())
		{
			if (Config.GM_STARTUP_INVULNERABLE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
				activeChar.setIsInvul(true);
			
			if (Config.GM_STARTUP_INVISIBLE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
				activeChar.getAppearance().setInvisible();
			
			if (Config.GM_STARTUP_SILENCE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
				activeChar.getSettingsManagement().setSilenceMode(true);
			
			if (Config.GM_STARTUP_DIET_MODE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
			{
				activeChar.getSettingsManagement().setDietMode(true);
				activeChar.refreshOverloaded();
			}
			
			if (Config.GM_STARTUP_AUTO_LIST
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
				GmListTable.getInstance().addGm(activeChar, false);
			else
				GmListTable.getInstance().addGm(activeChar, true);

			if (Config.GM_GIVE_SPECIAL_SKILLS)
				GMSkillTable.getInstance().addSkills(activeChar);
		}
		
		if (activeChar.getRace().ordinal() == 2)
		{
			L2Skill skill = SkillTable.getInstance().getInfo(294, 1);
			if (skill != null && activeChar.getSkillLevel(294) == 1)
			{
				if (GameTimeController.getInstance().isNowNight())
				{
					SystemMessage sm = new SystemMessage(SystemMessageId.NIGHT_EFFECT_S1_APPLIES);
					sm.addSkillName(294);
					sendPacket(sm);
				}
				else
				{
					SystemMessage sm = new SystemMessage(SystemMessageId.DAY_EFFECT_S1_DISAPPEARS);
					sm.addSkillName(294);
					sendPacket(sm);
				}
			}
		}
		
		// Set dead status if applies
		if (activeChar.getCurrentHp() < 0.5)
			activeChar.setIsDead(true);
		
		// Set Hero status if it applies
		if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()) 
				&& Hero.getInstance().getHeroes().get(activeChar.getObjectId()).getInteger(Hero.OBTAINED) > 0)
			activeChar.setHero(true);
		
		// pledge class for heroes and nobles
		setPledgeClass(activeChar);
		
		boolean showClanNotice = false;
		
		// Clan related checks are here
		if (activeChar.getClan() != null)
		{
			activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));
			
			notifyClanMembers(activeChar);
			
			notifySponsorOrApprentice(activeChar);
			
			ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
			
			if (clanHall != null)
			{
				if (!clanHall.getPaid())
                                {
                                        clanHall.updateDb();
					activeChar.sendPacket(SystemMessageId.MAKE_CLAN_HALL_PAYMENT_BY_S1_TOMORROW);
                                }
			}
			
			for (Siege siege : SiegeManager.getInstance().getSieges())
			{
				if (!siege.getIsInProgress())
					continue;
				
				if (siege.checkIsAttacker(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 1);
					activeChar.setSiegeSide(siege.getCastle().getCastleId());
				}
				
				else if (siege.checkIsDefender(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 2);
					activeChar.setSiegeSide(siege.getCastle().getCastleId());
				}
			}
			
			for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
			{
				if (!siege.getIsInProgress())
					continue;
				
				if (siege.checkIsAttacker(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 1);
					activeChar.setSiegeSide(siege.getFort().getFortId());
				}
				else if (siege.checkIsDefender(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 2);
					activeChar.setSiegeSide(siege.getFort().getFortId());
				}
			}
			
			sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
			sendPacket(new PledgeStatusChanged(activeChar.getClan()));
			
			// Residential skills support
			if (activeChar.getClan().getHasCastle() > 0)
				CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
			
			if (activeChar.getClan().getHasFort() > 0)
				FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
			
			// Unequip castle crown\circlet if clan has lost castle
			boolean hasCirclet = activeChar.getInventory().getItemByItemId(CastleManager.getCrown()) != null;
			if (hasCirclet && activeChar.getClan().getHasCastle() == 0)
			{
				L2ItemInstance crown = activeChar.getInventory().getItemByItemId(CastleManager.getCrown());
				if (crown.isEquipped())
				{
					activeChar.getInventory().unEquipItemInSlotAndRecord(crown.getLocationSlot());
					activeChar.sendPacket(new InventoryUpdate());
					activeChar.broadcastUserInfo();
				}
			}
			else
			{
				for (int i = 1; i < 10; i++)
				{
					hasCirclet = activeChar.getInventory().getItemByItemId(CastleManager.getCircletByCastleId(i)) != null;
					if (hasCirclet && i != activeChar.getClan().getHasCastle())
					{
						L2ItemInstance circlet = activeChar.getInventory().getItemByItemId(CastleManager.getCircletByCastleId(i));
						if (circlet.isEquipped())
						{
							activeChar.getInventory().unEquipItemInSlotAndRecord(circlet.getLocationSlot());
							activeChar.sendPacket(new InventoryUpdate());
							activeChar.broadcastUserInfo();
							break;
						}
					}
				}
			}
			
			showClanNotice = activeChar.getClan().isNoticeEnabled();
		}

                if (TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar) > 0)
                {
                    if (TerritoryWarManager.getInstance().isTWInProgress())
                        activeChar.setSiegeState((byte)1);
                    activeChar.setSiegeSide(TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar)); 
                }
		
		// Updating Seal of Strife Buff/Debuff
		if (SevenSigns.getInstance().isSealValidationPeriod()
		        && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) != SevenSigns.CABAL_NULL)
		{
			if (SevenSigns.getInstance().getPlayerCabal(activeChar.getObjectId()) != SevenSigns.CABAL_NULL)
			{
				if (SevenSigns.getInstance().getPlayerCabal(activeChar.getObjectId()) == SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE))
					activeChar.addSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
				else
					activeChar.addSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
			}
		}
		else
		{
			activeChar.removeSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
			activeChar.removeSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
		}
		
		activeChar.sendPacket(new UserInfo(activeChar));
		
		sendPacket(new ExBrExtraUserInfo(activeChar));
		
		// Send Macro List
		activeChar.getSettingsManagement().getMacros().sendUpdate();
		
		// Send Item List
		sendPacket(new ItemList(activeChar, false));
		
		// Send GG check
		activeChar.queryGameGuard();
		
		// Send Teleport Bookmark List
		sendPacket(new ExGetBookMarkInfo(activeChar));
		
		// Send Shortcuts
		sendPacket(new ShortCutInit(activeChar));
		
		// Send Action list
		activeChar.sendPacket(new ExBasicActionList(activeChar));
		
		// Send Skill list
		activeChar.sendSkillList();
		
		// Send Dye Information
		activeChar.sendPacket(new HennaInfo(activeChar));
		
		Quest.playerEnter(activeChar);

		if (!Config.DISABLE_TUTORIAL)
			loadTutorial(activeChar);
		
		// check for ilegal skills  
		if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)  
			 activeChar.checkAllowedSkills();
			
		for (Quest quest : QuestManager.getInstance().getAllManagedScripts())
		{
			if (quest != null && quest.getOnEnterWorld())
				quest.notifyEnterWorld(activeChar);
		}
		activeChar.sendPacket(new QuestList());
		
		if (!dontProtect && !activeChar.isInsideZone(ZONE_PEACE)) {
			activeChar.startSpawnProtection();
        }
		
		activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
		
		if (Config.CHAR_NAME_CACHE_UPDATE_ON_LOGIN)
			CharNameCacheManager.getInstance().getCache().updateCharName(activeChar);
		

		// character was into an L2Event
		if (L2Event.active && L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.isOnEvent(activeChar))
			L2Event.restoreChar(activeChar);
		else if (L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.connectionLossData.get(activeChar.getName()).eventType == L2EventType.EVENT_SIMPLE_TEAM)
			L2Event.restoreAndTeleChar(activeChar);
		
		// Wedding Checks
		if (Config.L2JMOD_ALLOW_WEDDING)
		{
			engage(activeChar);
			notifyPartner(activeChar, activeChar.getEventManagement().getPartnerId());
		}
		
		if (activeChar.isCursedWeaponEquipped())
		{
			CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
		}
		
		activeChar.updateEffectIcons();
		
		activeChar.sendPacket(new EtcStatusUpdate(activeChar));
		
		// Expand Skill
		activeChar.sendPacket(new ExStorageMaxCount(activeChar));
		
		sendPacket(new L2FriendList(activeChar));

		sendPacket(new SystemMessage(SystemMessageId.WELCOME_TO_LINEAGE));
		
		activeChar.sendMessage("This server uses L2DC files, a project founded by TheOne " +
				"and developed by the L2DC Dev Team at www.l2dragonclaw.net, " +
				"you can find our changelog and servers at www.l2dcproject.com");
		if (Config.DISPLAY_TEAM)
		{
			activeChar.sendMessage("L2DC Core Staff:");
			activeChar.sendMessage("Benurb, Evilus, Fordfrog, Ins0mnia, Kazumi, Pompinis");
			activeChar.sendMessage("L2DC Datapack Staff:");
			activeChar.sendMessage("Ex-Sadanobu, Karakan, Lunawang Zealar.");
			activeChar.sendMessage("Mixed Team Members Staff (Core & Datapack):");
			activeChar.sendMessage("Acoby, Elektra, Kazumi, Pompinis,  Probe, StevenP, TheOne.");
			activeChar.sendMessage("Mixed Team Members Staff (Datapack & Tester):");
			activeChar.sendMessage("RosT, Minideed.");
			activeChar.sendMessage("L2DC Technician Staff:");
			activeChar.sendMessage("Cyberfox.");
			activeChar.sendMessage("L2DC Other Staff Members:");
			activeChar.sendMessage("Nekys.");
		}
		if (Config.DISPLAY_SERVER_VERSION)
		{
			if (Config.SERVER_VERSION != null)
				activeChar.sendMessage("L2DC Server Version: " + Config.SERVER_VERSION);
		}
		activeChar.sendMessage("Copyright 2004-2010");
		
		SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
		Announcements.getInstance().showAnnouncements(activeChar);
		
		if (showClanNotice)
		{
			NpcHtmlMessage notice = new NpcHtmlMessage(1);
			notice.setFile(activeChar.getHtmlPrefix(), "data/html/clanNotice.htm");
			notice.replace("%clan_name%", activeChar.getClan().getName());
			notice.replace("%notice_text%", activeChar.getClan().getNotice().replaceAll("\r\n", "<br>"));
			notice.disableValidation();
			sendPacket(notice);
		}
		else if (Config.SERVER_NEWS)
		{
			String serverNews = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/servnews.htm");
			if (serverNews != null)
				sendPacket(new NpcHtmlMessage(1, serverNews));
		}
		
		if (Config.PETITIONING_ALLOWED)
			PetitionManager.getInstance().checkPetitionMessages(activeChar);
		
		if (activeChar.isAlikeDead()) // dead or fake dead
		{
			// no broadcast needed since the player will already spawn dead to others
			sendPacket(new Die(activeChar));
		}
		
		// Failed Login Attampts message
		if (Config.LOGIN_ATTEMPT_CHECK_ENABLE)
		{
			LoginServerThread.getInstance().displayFailedLoginAttemptsCount(activeChar.getAccountName());
		}
		
		notifyFriends(activeChar);
		
		activeChar.onPlayerEnter();
		
		sendPacket(new SkillCoolTime(activeChar));
		
		for (L2ItemInstance i : activeChar.getInventory().getItems())
		{
			if (i.isTimeLimitedItem())
				i.scheduleLifeTimeTask();
                         if (i.isShadowItem() && i.isEquipped())
                             i.decreaseMana(false);
		}
		
		if (Config.ENTER_MESSAGE_ENABLE) {
			sendPacket(new ExShowScreenMessage(
                    Config.ENTER_MESSAGE, Config.ENTER_MESSAGE_DURATION));
        }
		
		for (L2ItemInstance i : activeChar.getWarehouse().getItems())
		{
			if (i.isTimeLimitedItem())
			{
				i.scheduleLifeTimeTask();
			}
		}
		
		if (DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false))
			DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);
		
		if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
			activeChar.sendPacket(SystemMessageId.CLAN_MEMBERSHIP_TERMINATED);
		
		// remove combat flag before teleporting
		if (activeChar.getInventory().getItemByItemId(9819) != null)
		{
			Fort fort = FortManager.getInstance().getFort(activeChar);
			
			if (fort != null)
				FortSiegeManager.getInstance().dropCombatFlag(activeChar);
			else
			{
				int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819));
				activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
				activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true);
			}
		}
		
		// Delete cursed weapons if unequipped. and restore player karma to normal
		if (activeChar.getInventory().getItemByItemId(8689) != null)
		{
			L2ItemInstance cursed = activeChar.getInventory().getItemByItemId(8689);
			if (!cursed.isEquipped())
			{
				activeChar.destroyItem("Admin", cursed, null, false);
				if (activeChar.getKarma() > 0)
					activeChar.setKarma(0);
			}
		}
		else if (activeChar.getInventory().getItemByItemId(8190) != null)
		{
			L2ItemInstance cursed = activeChar.getInventory().getItemByItemId(8190);
			if (!cursed.isEquipped())
			{
				activeChar.destroyItem("Admin", cursed, null, false);
				if (activeChar.getKarma() > 0)
					activeChar.setKarma(0);
			}
		}
		// Attacker or spectator logging in to a siege zone. Actually should be checked for inside
		// castle only?
		if (!activeChar.isGM()
		// inside siege zone
		        && activeChar.isInsideZone(L2Character.ZONE_SIEGE)
		        // but non-participant or attacker
		        && (!activeChar.isInSiege() || activeChar.getSiegeState() < 2))
			activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
		
		RegionBBSManager.getInstance().changeCommunityBoard();
		CommunityServerThread.getInstance().sendPacket(new WorldInfo(activeChar, null, WorldInfo.TYPE_UPDATE_PLAYER_STATUS));
		
		TvTEvent.onLogin(activeChar);

		TvTCustomEvent.onLogin(activeChar);
		
		// character was into an L2EventRaid
		if ((L2EventRaid._started || L2EventRaid._teleport) && L2Event.connectionLossData.containsKey(activeChar.getName()))
			L2EventRaid.addDisconnectedPlayer(activeChar);
		else if (L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.connectionLossData.get(activeChar.getName()).eventType == L2EventType.EVENT_RAID)
		{
			L2EventRaid.restoreChar(activeChar);
			L2EventRaid.removePlayer(activeChar);
		}

		L2ClassMasterInstance.showQuestionMark(activeChar);
		
		int birth = activeChar.getEventManagement().CheckBirthDay();
		if (birth == 0)
		{
			activeChar.sendPacket(SystemMessageId.YOUR_BIRTHDAY_GIFT_HAS_ARRIVED);
			activeChar.sendPacket(new ExNotifyBirthDay());
		}
		else if (birth != -1)
		{
			SystemMessage sm = new SystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_UNTIL_YOUR_CHARACTERS_BIRTHDAY);
			sm.addString(Integer.toString(birth));
			activeChar.sendPacket(sm);
		}
		
		if(!activeChar.getPremiumItemList().isEmpty())
			activeChar.notifyPremiumItem();
		
		if (MailManager.getInstance().deliverMailsForCharId(activeChar.getObjectId()) > 0 
				|| MailManager.getInstance().UnreadMailsForCharId(activeChar.getObjectId()) > 0)
		{
			activeChar.sendPacket(ExNoticePostArrived.valueOf(true));
			activeChar.sendPacket(SystemMessageId2.UNREAD_MAIL);
		}
		
		if (activeChar.isTransformed() == true && activeChar.getTransformationId() == 105)
		{
			activeChar.untransform();
		}
		
		if (!Config.ALT_DISABLE_LOGIN_PROTECTION)
			activeChar.startProtection();
	}
	
	/**
	 * @param activeChar
	 */
	private void engage(L2PcInstance cha)
	{
		int _chaid = cha.getObjectId();
		
		for (Couple cl : CoupleManager.getInstance().getCouples())
		{
			if (cl.getPlayer1Id() == _chaid || cl.getPlayer2Id() == _chaid)
			{
				if (cl.getMaried())
					cha.getEventManagement().setMarried(true);
				
				cha.getEventManagement().setCoupleId(cl.getId());
				
				if (cl.getPlayer1Id() == _chaid)
					cha.getEventManagement().setPartnerId(cl.getPlayer2Id());
				
				else
					cha.getEventManagement().setPartnerId(cl.getPlayer1Id());
			}
		}
	}
	
	/**
	 * @param activeChar
	 *            partnerid
	 */
	private void notifyPartner(L2PcInstance cha, int partnerId)
	{
		if (cha.getEventManagement().getPartnerId() != 0)
		{
			L2PcInstance partner;
			int objId = cha.getEventManagement().getPartnerId();
			
			try
			{
				partner = L2World.getInstance().getPlayer(cha.getEventManagement().getPartnerId());
				
				if (partner != null)
					partner.sendMessage("Your Partner has logged in.");
				
				partner = null;
			}
			catch (ClassCastException cce)
			{
				_log.warning("Wedding Error: ID " + objId + " is now owned by a(n) "
				        + L2World.getInstance().findObject(objId).getClass().getSimpleName());
			}
		}
	}
	
	/**
	 * @param activeChar
	 */
	private void notifyFriends(L2PcInstance cha)
	{
		SystemMessage sm = new SystemMessage(SystemMessageId.FRIEND_S1_HAS_LOGGED_IN);
		sm.addString(cha.getName());

		for (FriendsListEntry entry : cha.getRelationsManagement().getFriendsList().getFriends())
		{
			L2PcInstance friend = L2World.getInstance().getPlayer(entry.getFriendName());
			
			if (friend != null) // friend logged in.
			{
				FriendsListEntry friendEntry = friend.getRelationsManagement().getFriendsList().getFriend(cha.getObjectId());
				friendEntry.setOnline(true);
				friend.sendPacket(new L2FriendStatus(friendEntry));
				friend.sendPacket(sm);
			}
		}
	}
	
	/**
	 * @param activeChar
	 */
	private void notifyClanMembers(L2PcInstance activeChar)
	{
		L2Clan clan = activeChar.getClan();
		
		// This null check may not be needed anymore since notifyClanMembers is called from within a
		// null check already. Please remove if we're certain it's ok to do so.
		if (clan != null)
		{
			clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
			SystemMessage msg = new SystemMessage(SystemMessageId.CLAN_MEMBER_S1_LOGGED_IN);
			msg.addString(activeChar.getName());
			clan.broadcastToOtherOnlineMembers(msg, activeChar);
			msg = null;
			clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
		}
	}
	
	/**
	 * @param activeChar
	 */
	private void notifySponsorOrApprentice(L2PcInstance activeChar)
	{
		if (activeChar.getSponsor() != 0)
		{
			L2PcInstance sponsor = L2World.getInstance().getPlayer(activeChar.getSponsor());
			
			if (sponsor != null)
			{
				SystemMessage msg = new SystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN);
				msg.addString(activeChar.getName());
				sponsor.sendPacket(msg);
			}
		}
		else if (activeChar.getApprentice() != 0)
		{
			L2PcInstance apprentice = L2World.getInstance().getPlayer(activeChar.getApprentice());
			
			if (apprentice != null)
			{
				SystemMessage msg = new SystemMessage(SystemMessageId.YOUR_SPONSOR_C1_HAS_LOGGED_IN);
				msg.addString(activeChar.getName());
				apprentice.sendPacket(msg);
			}
		}
	}
	
	private void loadTutorial(L2PcInstance player)
	{
		QuestState qs = player.getQuestState("Tutorial");
		
		if (qs != null)
			qs.getQuest().notifyEvent("UC", null, player);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.l2dc.gameserver.clientpackets.ClientBasePacket#getType()
	 */
	@Override
	public String getType()
	{
		return _C__03_ENTERWORLD;
	}
	
	private void setPledgeClass(L2PcInstance activeChar)
	{
		int pledgeClass = 0;
		
		// This null check may not be needed anymore since setPledgeClass is called from within a
		// null check already. Please remove if we're certain it's ok to do so.
		if (activeChar.getClan() != null)
			pledgeClass = activeChar.getClan().getClanMember(activeChar.getObjectId()).calculatePledgeClass(activeChar);
		
		if (activeChar.isNoble() && pledgeClass < 5)
			pledgeClass = 5;
		
		if (activeChar.getOlympiadManagement().isHero() && pledgeClass < 8)
			pledgeClass = 8;
		
		activeChar.setPledgeClass(pledgeClass);
	}
}
Добавлено через 1 минуту
а точнее что эта за хрень?

Последний раз редактировалось krisadr; 27.08.2010 в 15:38. Причина: Добавлено сообщение
krisadr вне форума Ответить с цитированием
Непрочитано 27.08.2010, 15:41   #2
Изгнанные

По умолчанию Re: EnterWorld.java

Цитата:
Сообщение от krisadr Посмотреть сообщение

Код:
/*
 * This program 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.
 * 
 * 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
 * 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 com.l2dc.gameserver.network.clientpackets.player;

import static com.l2dc.gameserver.model.actor.L2Character.ZONE_PEACE;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2dc.Config;
import com.l2dc.gameserver.Announcements;
import com.l2dc.gameserver.DisconnectManager;
import com.l2dc.gameserver.GameTimeController;
import com.l2dc.gameserver.GmListTable;
import com.l2dc.gameserver.LoginServerThread;
import com.l2dc.gameserver.SevenSigns;
import com.l2dc.gameserver.TaskPriority;
import com.l2dc.gameserver.cache.HtmCache;
import com.l2dc.gameserver.cache.charnames.CharNameCacheManager;
import com.l2dc.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2dc.gameserver.datatables.AdminCommandAccessRights;
import com.l2dc.gameserver.datatables.GMSkillTable;
import com.l2dc.gameserver.datatables.MapRegionTable;
import com.l2dc.gameserver.datatables.SkillTable;
import com.l2dc.gameserver.instancemanager.CastleManager;
import com.l2dc.gameserver.instancemanager.ClanHallManager;
import com.l2dc.gameserver.instancemanager.CoupleManager;
import com.l2dc.gameserver.instancemanager.CursedWeaponsManager;
import com.l2dc.gameserver.instancemanager.DimensionalRiftManager;
import com.l2dc.gameserver.instancemanager.FortManager;
import com.l2dc.gameserver.instancemanager.FortSiegeManager;
import com.l2dc.gameserver.instancemanager.IPManager;
import com.l2dc.gameserver.instancemanager.InstanceManager;
import com.l2dc.gameserver.instancemanager.MailManager;
import com.l2dc.gameserver.instancemanager.PetitionManager;
import com.l2dc.gameserver.instancemanager.QuestManager;
import com.l2dc.gameserver.instancemanager.SiegeManager;
import com.l2dc.gameserver.instancemanager.TerritoryWarManager;
import com.l2dc.gameserver.model.L2Clan;
import com.l2dc.gameserver.model.L2ItemInstance;
import com.l2dc.gameserver.model.L2Skill;
import com.l2dc.gameserver.model.L2World;
import com.l2dc.gameserver.model.actor.L2Character;
import com.l2dc.gameserver.model.actor.instance.L2ClassMasterInstance;
import com.l2dc.gameserver.model.actor.instance.L2PcInstance;
import com.l2dc.gameserver.model.actor.relations.FriendsListEntry;
import com.l2dc.gameserver.model.entity.ClanHall;
import com.l2dc.gameserver.model.entity.Couple;
import com.l2dc.gameserver.model.entity.Fort;
import com.l2dc.gameserver.model.entity.FortSiege;
import com.l2dc.gameserver.model.entity.Hero;
import com.l2dc.gameserver.model.entity.L2Event;
import com.l2dc.gameserver.model.entity.L2EventRaid;
import com.l2dc.gameserver.model.entity.Siege;
import com.l2dc.gameserver.model.entity.tvt.TvTCustomEvent;
import com.l2dc.gameserver.model.entity.tvt.TvTEvent;
import com.l2dc.gameserver.model.quest.Quest;
import com.l2dc.gameserver.model.quest.QuestState;
import com.l2dc.gameserver.network.SystemMessageId;
import com.l2dc.gameserver.network.SystemMessageId2;
import com.l2dc.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2dc.gameserver.network.communityserver.CommunityServerThread;
import com.l2dc.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2dc.gameserver.network.serverpackets.Die;
import com.l2dc.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2dc.gameserver.network.serverpackets.ExBasicActionList;
import com.l2dc.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2dc.gameserver.network.serverpackets.ExGetBookMarkInfo;
import com.l2dc.gameserver.network.serverpackets.ExNoticePostArrived;
import com.l2dc.gameserver.network.serverpackets.ExNotifyBirthDay;
import com.l2dc.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2dc.gameserver.network.serverpackets.ExStorageMaxCount;
import com.l2dc.gameserver.network.serverpackets.HennaInfo;
import com.l2dc.gameserver.network.serverpackets.InventoryUpdate;
import com.l2dc.gameserver.network.serverpackets.ItemList;
import com.l2dc.gameserver.network.serverpackets.L2FriendList;
import com.l2dc.gameserver.network.serverpackets.L2FriendStatus;
import com.l2dc.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2dc.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2dc.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import com.l2dc.gameserver.network.serverpackets.PledgeSkillList;
import com.l2dc.gameserver.network.serverpackets.PledgeStatusChanged;
import com.l2dc.gameserver.network.serverpackets.QuestList;
import com.l2dc.gameserver.network.serverpackets.ShortCutInit;
import com.l2dc.gameserver.network.serverpackets.SkillCoolTime;
import com.l2dc.gameserver.network.serverpackets.SystemMessage;
import com.l2dc.gameserver.network.serverpackets.UserInfo;
import com.l2dc.util.StringUtil;
import com.l2dc.util.EventData.L2EventType;

/**
 * Enter World Packet Handler
 * <p>
 * 0000: 03 <p>
 * packet format rev87 bddddbdcccccccccccccccccccc
 * <p>
 */
public class EnterWorld extends L2GameClientPacket
{
	private static final String _C__03_ENTERWORLD = "[C] 03 EnterWorld";
	
	private static final Logger _log = Logger.getLogger(EnterWorld.class.getName());
	private static final Logger _logAccount = Logger.getLogger("account");
	
	private String _userHost;
	private String _routeHop1;
	private String _routeHop2;
	private String _routeHop3;
	private String _routeHop4;

	public TaskPriority getPriority()
	{
		return TaskPriority.PR_URGENT;
	}
	
	@Override
	protected void readImpl()
	{
		readB(new byte[32]);	// Unknown Byte Array
		readD();				// Unknown Value
		readD();				// Unknown Value
		readD();				// Unknown Value
		readD();				// Unknown Value
		readB(new byte[32]);	// Unknown Byte Array
		readD();				// Unknown Value
		_userHost  = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop1 = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop2 = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop3 = readC()+"."+readC()+"."+readC()+"."+readC();
		_routeHop4 = readC()+"."+readC()+"."+readC()+"."+readC();
	}
	
	@Override
	protected void runImpl()
	{
		L2PcInstance activeChar = getClient().getActiveChar();
		
		if (activeChar == null)
		{
			_log.warning("EnterWorld failed! activeChar returned 'null'.");
			getClient().closeNow();
			return;
		}
		
		if (_logAccount.isLoggable(Level.INFO))
		{
			_logAccount.info(getClient().toString());
		}
		
		final boolean dontProtect = DisconnectManager.getInstance().removeTimer(activeChar.getObjectId());

		LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(),
				_userHost, _routeHop1, _routeHop2, _routeHop3, _routeHop4);
		
		// Multibox Protection Engine
		if (Config.MULTIBOX_PROTECTION_ENABLED)
			IPManager.getInstance().multiboxKickTask(activeChar, _userHost);
		
		// Restore to instanced area if enabled
		if (Config.RESTORE_PLAYER_INSTANCE)
			activeChar.setInstanceId(InstanceManager.getInstance().getPlayerInstance(activeChar.getObjectId()));
		else
		{
			int instanceId = InstanceManager.getInstance().getPlayerInstance(activeChar.getObjectId());
			if (instanceId > 0)
				InstanceManager.getInstance().getInstance(instanceId).removePlayer(activeChar.getObjectId());
		}
		
		if (activeChar.getPet() != null)
			activeChar.getPet().setInstanceId(activeChar.getInstanceId());
		
		// Restore Vitality
		if (Config.RECOVER_VITALITY_ON_RECONNECT || Config.ENABLE_VITALITY)
			activeChar.getVitalityManagement().restoreVitality();
		
		if (L2World.getInstance().getPlayer(activeChar.getObjectId()) != null)
		{
			if (_log.isLoggable(Level.WARNING))
			{
				_log.warning(StringUtil.concat("User already exists in Object ID map! User ", activeChar.getName(), " is a character clone."));
			}
		}
		// Set the Client IP property
		activeChar.setClientIP();
		
		// Apply special GM properties to the GM when entering
		if (activeChar.isGM())
		{
			if (Config.GM_STARTUP_INVULNERABLE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
				activeChar.setIsInvul(true);
			
			if (Config.GM_STARTUP_INVISIBLE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
				activeChar.getAppearance().setInvisible();
			
			if (Config.GM_STARTUP_SILENCE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
				activeChar.getSettingsManagement().setSilenceMode(true);
			
			if (Config.GM_STARTUP_DIET_MODE
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
			{
				activeChar.getSettingsManagement().setDietMode(true);
				activeChar.refreshOverloaded();
			}
			
			if (Config.GM_STARTUP_AUTO_LIST
			        && AdminCommandAccessRights.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
				GmListTable.getInstance().addGm(activeChar, false);
			else
				GmListTable.getInstance().addGm(activeChar, true);

			if (Config.GM_GIVE_SPECIAL_SKILLS)
				GMSkillTable.getInstance().addSkills(activeChar);
		}
		
		if (activeChar.getRace().ordinal() == 2)
		{
			L2Skill skill = SkillTable.getInstance().getInfo(294, 1);
			if (skill != null && activeChar.getSkillLevel(294) == 1)
			{
				if (GameTimeController.getInstance().isNowNight())
				{
					SystemMessage sm = new SystemMessage(SystemMessageId.NIGHT_EFFECT_S1_APPLIES);
					sm.addSkillName(294);
					sendPacket(sm);
				}
				else
				{
					SystemMessage sm = new SystemMessage(SystemMessageId.DAY_EFFECT_S1_DISAPPEARS);
					sm.addSkillName(294);
					sendPacket(sm);
				}
			}
		}
		
		// Set dead status if applies
		if (activeChar.getCurrentHp() < 0.5)
			activeChar.setIsDead(true);
		
		// Set Hero status if it applies
		if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()) 
				&& Hero.getInstance().getHeroes().get(activeChar.getObjectId()).getInteger(Hero.OBTAINED) > 0)
			activeChar.setHero(true);
		
		// pledge class for heroes and nobles
		setPledgeClass(activeChar);
		
		boolean showClanNotice = false;
		
		// Clan related checks are here
		if (activeChar.getClan() != null)
		{
			activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));
			
			notifyClanMembers(activeChar);
			
			notifySponsorOrApprentice(activeChar);
			
			ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
			
			if (clanHall != null)
			{
				if (!clanHall.getPaid())
                                {
                                        clanHall.updateDb();
					activeChar.sendPacket(SystemMessageId.MAKE_CLAN_HALL_PAYMENT_BY_S1_TOMORROW);
                                }
			}
			
			for (Siege siege : SiegeManager.getInstance().getSieges())
			{
				if (!siege.getIsInProgress())
					continue;
				
				if (siege.checkIsAttacker(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 1);
					activeChar.setSiegeSide(siege.getCastle().getCastleId());
				}
				
				else if (siege.checkIsDefender(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 2);
					activeChar.setSiegeSide(siege.getCastle().getCastleId());
				}
			}
			
			for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
			{
				if (!siege.getIsInProgress())
					continue;
				
				if (siege.checkIsAttacker(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 1);
					activeChar.setSiegeSide(siege.getFort().getFortId());
				}
				else if (siege.checkIsDefender(activeChar.getClan()))
				{
					activeChar.setSiegeState((byte) 2);
					activeChar.setSiegeSide(siege.getFort().getFortId());
				}
			}
			
			sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
			sendPacket(new PledgeStatusChanged(activeChar.getClan()));
			
			// Residential skills support
			if (activeChar.getClan().getHasCastle() > 0)
				CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
			
			if (activeChar.getClan().getHasFort() > 0)
				FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
			
			// Unequip castle crown\circlet if clan has lost castle
			boolean hasCirclet = activeChar.getInventory().getItemByItemId(CastleManager.getCrown()) != null;
			if (hasCirclet && activeChar.getClan().getHasCastle() == 0)
			{
				L2ItemInstance crown = activeChar.getInventory().getItemByItemId(CastleManager.getCrown());
				if (crown.isEquipped())
				{
					activeChar.getInventory().unEquipItemInSlotAndRecord(crown.getLocationSlot());
					activeChar.sendPacket(new InventoryUpdate());
					activeChar.broadcastUserInfo();
				}
			}
			else
			{
				for (int i = 1; i < 10; i++)
				{
					hasCirclet = activeChar.getInventory().getItemByItemId(CastleManager.getCircletByCastleId(i)) != null;
					if (hasCirclet && i != activeChar.getClan().getHasCastle())
					{
						L2ItemInstance circlet = activeChar.getInventory().getItemByItemId(CastleManager.getCircletByCastleId(i));
						if (circlet.isEquipped())
						{
							activeChar.getInventory().unEquipItemInSlotAndRecord(circlet.getLocationSlot());
							activeChar.sendPacket(new InventoryUpdate());
							activeChar.broadcastUserInfo();
							break;
						}
					}
				}
			}
			
			showClanNotice = activeChar.getClan().isNoticeEnabled();
		}

                if (TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar) > 0)
                {
                    if (TerritoryWarManager.getInstance().isTWInProgress())
                        activeChar.setSiegeState((byte)1);
                    activeChar.setSiegeSide(TerritoryWarManager.getInstance().getRegisteredTerritoryId(activeChar)); 
                }
		
		// Updating Seal of Strife Buff/Debuff
		if (SevenSigns.getInstance().isSealValidationPeriod()
		        && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) != SevenSigns.CABAL_NULL)
		{
			if (SevenSigns.getInstance().getPlayerCabal(activeChar.getObjectId()) != SevenSigns.CABAL_NULL)
			{
				if (SevenSigns.getInstance().getPlayerCabal(activeChar.getObjectId()) == SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE))
					activeChar.addSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
				else
					activeChar.addSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
			}
		}
		else
		{
			activeChar.removeSkill(SkillTable.FrequentSkill.THE_VICTOR_OF_WAR.getSkill());
			activeChar.removeSkill(SkillTable.FrequentSkill.THE_VANQUISHED_OF_WAR.getSkill());
		}
		
		activeChar.sendPacket(new UserInfo(activeChar));
		
		sendPacket(new ExBrExtraUserInfo(activeChar));
		
		// Send Macro List
		activeChar.getSettingsManagement().getMacros().sendUpdate();
		
		// Send Item List
		sendPacket(new ItemList(activeChar, false));
		
		// Send GG check
		activeChar.queryGameGuard();
		
		// Send Teleport Bookmark List
		sendPacket(new ExGetBookMarkInfo(activeChar));
		
		// Send Shortcuts
		sendPacket(new ShortCutInit(activeChar));
		
		// Send Action list
		activeChar.sendPacket(new ExBasicActionList(activeChar));
		
		// Send Skill list
		activeChar.sendSkillList();
		
		// Send Dye Information
		activeChar.sendPacket(new HennaInfo(activeChar));
		
		Quest.playerEnter(activeChar);

		if (!Config.DISABLE_TUTORIAL)
			loadTutorial(activeChar);
		
		// check for ilegal skills  
		if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)  
			 activeChar.checkAllowedSkills();
			
		for (Quest quest : QuestManager.getInstance().getAllManagedScripts())
		{
			if (quest != null && quest.getOnEnterWorld())
				quest.notifyEnterWorld(activeChar);
		}
		activeChar.sendPacket(new QuestList());
		
		if (!dontProtect && !activeChar.isInsideZone(ZONE_PEACE)) {
			activeChar.startSpawnProtection();
        }
		
		activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
		
		if (Config.CHAR_NAME_CACHE_UPDATE_ON_LOGIN)
			CharNameCacheManager.getInstance().getCache().updateCharName(activeChar);
		

		// character was into an L2Event
		if (L2Event.active && L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.isOnEvent(activeChar))
			L2Event.restoreChar(activeChar);
		else if (L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.connectionLossData.get(activeChar.getName()).eventType == L2EventType.EVENT_SIMPLE_TEAM)
			L2Event.restoreAndTeleChar(activeChar);
		
		// Wedding Checks
		if (Config.L2JMOD_ALLOW_WEDDING)
		{
			engage(activeChar);
			notifyPartner(activeChar, activeChar.getEventManagement().getPartnerId());
		}
		
		if (activeChar.isCursedWeaponEquipped())
		{
			CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
		}
		
		activeChar.updateEffectIcons();
		
		activeChar.sendPacket(new EtcStatusUpdate(activeChar));
		
		// Expand Skill
		activeChar.sendPacket(new ExStorageMaxCount(activeChar));
		
		sendPacket(new L2FriendList(activeChar));

		sendPacket(new SystemMessage(SystemMessageId.WELCOME_TO_LINEAGE));
		
		activeChar.sendMessage("This server uses L2DC files, a project founded by TheOne " +
				"and developed by the L2DC Dev Team at www.l2dragonclaw.net, " +
				"you can find our changelog and servers at www.l2dcproject.com");
		if (Config.DISPLAY_TEAM)
		{
			activeChar.sendMessage("L2DC Core Staff:");
			activeChar.sendMessage("Benurb, Evilus, Fordfrog, Ins0mnia, Kazumi, Pompinis");
			activeChar.sendMessage("L2DC Datapack Staff:");
			activeChar.sendMessage("Ex-Sadanobu, Karakan, Lunawang Zealar.");
			activeChar.sendMessage("Mixed Team Members Staff (Core & Datapack):");
			activeChar.sendMessage("Acoby, Elektra, Kazumi, Pompinis,  Probe, StevenP, TheOne.");
			activeChar.sendMessage("Mixed Team Members Staff (Datapack & Tester):");
			activeChar.sendMessage("RosT, Minideed.");
			activeChar.sendMessage("L2DC Technician Staff:");
			activeChar.sendMessage("Cyberfox.");
			activeChar.sendMessage("L2DC Other Staff Members:");
			activeChar.sendMessage("Nekys.");
		}
		if (Config.DISPLAY_SERVER_VERSION)
		{
			if (Config.SERVER_VERSION != null)
				activeChar.sendMessage("L2DC Server Version: " + Config.SERVER_VERSION);
		}
		activeChar.sendMessage("Copyright 2004-2010");
		
		SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
		Announcements.getInstance().showAnnouncements(activeChar);
		
		if (showClanNotice)
		{
			NpcHtmlMessage notice = new NpcHtmlMessage(1);
			notice.setFile(activeChar.getHtmlPrefix(), "data/html/clanNotice.htm");
			notice.replace("%clan_name%", activeChar.getClan().getName());
			notice.replace("%notice_text%", activeChar.getClan().getNotice().replaceAll("\r\n", "<br>"));
			notice.disableValidation();
			sendPacket(notice);
		}
		else if (Config.SERVER_NEWS)
		{
			String serverNews = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/servnews.htm");
			if (serverNews != null)
				sendPacket(new NpcHtmlMessage(1, serverNews));
		}
		
		if (Config.PETITIONING_ALLOWED)
			PetitionManager.getInstance().checkPetitionMessages(activeChar);
		
		if (activeChar.isAlikeDead()) // dead or fake dead
		{
			// no broadcast needed since the player will already spawn dead to others
			sendPacket(new Die(activeChar));
		}
		
		// Failed Login Attampts message
		if (Config.LOGIN_ATTEMPT_CHECK_ENABLE)
		{
			LoginServerThread.getInstance().displayFailedLoginAttemptsCount(activeChar.getAccountName());
		}
		
		notifyFriends(activeChar);
		
		activeChar.onPlayerEnter();
		
		sendPacket(new SkillCoolTime(activeChar));
		
		for (L2ItemInstance i : activeChar.getInventory().getItems())
		{
			if (i.isTimeLimitedItem())
				i.scheduleLifeTimeTask();
                         if (i.isShadowItem() && i.isEquipped())
                             i.decreaseMana(false);
		}
		
		if (Config.ENTER_MESSAGE_ENABLE) {
			sendPacket(new ExShowScreenMessage(
                    Config.ENTER_MESSAGE, Config.ENTER_MESSAGE_DURATION));
        }
		
		for (L2ItemInstance i : activeChar.getWarehouse().getItems())
		{
			if (i.isTimeLimitedItem())
			{
				i.scheduleLifeTimeTask();
			}
		}
		
		if (DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false))
			DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);
		
		if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
			activeChar.sendPacket(SystemMessageId.CLAN_MEMBERSHIP_TERMINATED);
		
		// remove combat flag before teleporting
		if (activeChar.getInventory().getItemByItemId(9819) != null)
		{
			Fort fort = FortManager.getInstance().getFort(activeChar);
			
			if (fort != null)
				FortSiegeManager.getInstance().dropCombatFlag(activeChar);
			else
			{
				int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819));
				activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
				activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true);
			}
		}
		
		// Delete cursed weapons if unequipped. and restore player karma to normal
		if (activeChar.getInventory().getItemByItemId(8689) != null)
		{
			L2ItemInstance cursed = activeChar.getInventory().getItemByItemId(8689);
			if (!cursed.isEquipped())
			{
				activeChar.destroyItem("Admin", cursed, null, false);
				if (activeChar.getKarma() > 0)
					activeChar.setKarma(0);
			}
		}
		else if (activeChar.getInventory().getItemByItemId(8190) != null)
		{
			L2ItemInstance cursed = activeChar.getInventory().getItemByItemId(8190);
			if (!cursed.isEquipped())
			{
				activeChar.destroyItem("Admin", cursed, null, false);
				if (activeChar.getKarma() > 0)
					activeChar.setKarma(0);
			}
		}
		// Attacker or spectator logging in to a siege zone. Actually should be checked for inside
		// castle only?
		if (!activeChar.isGM()
		// inside siege zone
		        && activeChar.isInsideZone(L2Character.ZONE_SIEGE)
		        // but non-participant or attacker
		        && (!activeChar.isInSiege() || activeChar.getSiegeState() < 2))
			activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
		
		RegionBBSManager.getInstance().changeCommunityBoard();
		CommunityServerThread.getInstance().sendPacket(new WorldInfo(activeChar, null, WorldInfo.TYPE_UPDATE_PLAYER_STATUS));
		
		TvTEvent.onLogin(activeChar);

		TvTCustomEvent.onLogin(activeChar);
		
		// character was into an L2EventRaid
		if ((L2EventRaid._started || L2EventRaid._teleport) && L2Event.connectionLossData.containsKey(activeChar.getName()))
			L2EventRaid.addDisconnectedPlayer(activeChar);
		else if (L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.connectionLossData.get(activeChar.getName()).eventType == L2EventType.EVENT_RAID)
		{
			L2EventRaid.restoreChar(activeChar);
			L2EventRaid.removePlayer(activeChar);
		}

		L2ClassMasterInstance.showQuestionMark(activeChar);
		
		int birth = activeChar.getEventManagement().CheckBirthDay();
		if (birth == 0)
		{
			activeChar.sendPacket(SystemMessageId.YOUR_BIRTHDAY_GIFT_HAS_ARRIVED);
			activeChar.sendPacket(new ExNotifyBirthDay());
		}
		else if (birth != -1)
		{
			SystemMessage sm = new SystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_UNTIL_YOUR_CHARACTERS_BIRTHDAY);
			sm.addString(Integer.toString(birth));
			activeChar.sendPacket(sm);
		}
		
		if(!activeChar.getPremiumItemList().isEmpty())
			activeChar.notifyPremiumItem();
		
		if (MailManager.getInstance().deliverMailsForCharId(activeChar.getObjectId()) > 0 
				|| MailManager.getInstance().UnreadMailsForCharId(activeChar.getObjectId()) > 0)
		{
			activeChar.sendPacket(ExNoticePostArrived.valueOf(true));
			activeChar.sendPacket(SystemMessageId2.UNREAD_MAIL);
		}
		
		if (activeChar.isTransformed() == true && activeChar.getTransformationId() == 105)
		{
			activeChar.untransform();
		}
		
		if (!Config.ALT_DISABLE_LOGIN_PROTECTION)
			activeChar.startProtection();
	}
	
	/**
	 * @param activeChar
	 */
	private void engage(L2PcInstance cha)
	{
		int _chaid = cha.getObjectId();
		
		for (Couple cl : CoupleManager.getInstance().getCouples())
		{
			if (cl.getPlayer1Id() == _chaid || cl.getPlayer2Id() == _chaid)
			{
				if (cl.getMaried())
					cha.getEventManagement().setMarried(true);
				
				cha.getEventManagement().setCoupleId(cl.getId());
				
				if (cl.getPlayer1Id() == _chaid)
					cha.getEventManagement().setPartnerId(cl.getPlayer2Id());
				
				else
					cha.getEventManagement().setPartnerId(cl.getPlayer1Id());
			}
		}
	}
	
	/**
	 * @param activeChar
	 *            partnerid
	 */
	private void notifyPartner(L2PcInstance cha, int partnerId)
	{
		if (cha.getEventManagement().getPartnerId() != 0)
		{
			L2PcInstance partner;
			int objId = cha.getEventManagement().getPartnerId();
			
			try
			{
				partner = L2World.getInstance().getPlayer(cha.getEventManagement().getPartnerId());
				
				if (partner != null)
					partner.sendMessage("Your Partner has logged in.");
				
				partner = null;
			}
			catch (ClassCastException cce)
			{
				_log.warning("Wedding Error: ID " + objId + " is now owned by a(n) "
				        + L2World.getInstance().findObject(objId).getClass().getSimpleName());
			}
		}
	}
	
	/**
	 * @param activeChar
	 */
	private void notifyFriends(L2PcInstance cha)
	{
		SystemMessage sm = new SystemMessage(SystemMessageId.FRIEND_S1_HAS_LOGGED_IN);
		sm.addString(cha.getName());

		for (FriendsListEntry entry : cha.getRelationsManagement().getFriendsList().getFriends())
		{
			L2PcInstance friend = L2World.getInstance().getPlayer(entry.getFriendName());
			
			if (friend != null) // friend logged in.
			{
				FriendsListEntry friendEntry = friend.getRelationsManagement().getFriendsList().getFriend(cha.getObjectId());
				friendEntry.setOnline(true);
				friend.sendPacket(new L2FriendStatus(friendEntry));
				friend.sendPacket(sm);
			}
		}
	}
	
	/**
	 * @param activeChar
	 */
	private void notifyClanMembers(L2PcInstance activeChar)
	{
		L2Clan clan = activeChar.getClan();
		
		// This null check may not be needed anymore since notifyClanMembers is called from within a
		// null check already. Please remove if we're certain it's ok to do so.
		if (clan != null)
		{
			clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
			SystemMessage msg = new SystemMessage(SystemMessageId.CLAN_MEMBER_S1_LOGGED_IN);
			msg.addString(activeChar.getName());
			clan.broadcastToOtherOnlineMembers(msg, activeChar);
			msg = null;
			clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
		}
	}
	
	/**
	 * @param activeChar
	 */
	private void notifySponsorOrApprentice(L2PcInstance activeChar)
	{
		if (activeChar.getSponsor() != 0)
		{
			L2PcInstance sponsor = L2World.getInstance().getPlayer(activeChar.getSponsor());
			
			if (sponsor != null)
			{
				SystemMessage msg = new SystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN);
				msg.addString(activeChar.getName());
				sponsor.sendPacket(msg);
			}
		}
		else if (activeChar.getApprentice() != 0)
		{
			L2PcInstance apprentice = L2World.getInstance().getPlayer(activeChar.getApprentice());
			
			if (apprentice != null)
			{
				SystemMessage msg = new SystemMessage(SystemMessageId.YOUR_SPONSOR_C1_HAS_LOGGED_IN);
				msg.addString(activeChar.getName());
				apprentice.sendPacket(msg);
			}
		}
	}
	
	private void loadTutorial(L2PcInstance player)
	{
		QuestState qs = player.getQuestState("Tutorial");
		
		if (qs != null)
			qs.getQuest().notifyEvent("UC", null, player);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.l2dc.gameserver.clientpackets.ClientBasePacket#getType()
	 */
	@Override
	public String getType()
	{
		return _C__03_ENTERWORLD;
	}
	
	private void setPledgeClass(L2PcInstance activeChar)
	{
		int pledgeClass = 0;
		
		// This null check may not be needed anymore since setPledgeClass is called from within a
		// null check already. Please remove if we're certain it's ok to do so.
		if (activeChar.getClan() != null)
			pledgeClass = activeChar.getClan().getClanMember(activeChar.getObjectId()).calculatePledgeClass(activeChar);
		
		if (activeChar.isNoble() && pledgeClass < 5)
			pledgeClass = 5;
		
		if (activeChar.getOlympiadManagement().isHero() && pledgeClass < 8)
			pledgeClass = 8;
		
		activeChar.setPledgeClass(pledgeClass);
	}
}
Добавлено через 1 минуту
а точнее что эта за хрень?
Код:
	private void loadTutorial(L2PcInstance player)
	{
		QuestState qs = player.getQuestState("Tutorial");
		
		if (qs != null)
			qs.getQuest().notifyEvent("UC", null, player);
	}
GoodShadow вне форума Отправить сообщение для GoodShadow с помощью ICQ Отправить сообщение для GoodShadow с помощью Skype™ Ответить с цитированием
Сказали спасибо:
Непрочитано 27.08.2010, 15:45   #3
Аватар для krisadr
Пользователь

Автор темы (Топик Стартер) Re: EnterWorld.java

эммм... эт то ясно а что оно означает и вообще для чего нужна
krisadr вне форума Ответить с цитированием
Непрочитано 27.08.2010, 16:31   #4
Изгнанные

Wink Re: EnterWorld.java

Идет проверка на квест туториала, а если его нет то выполнается notifyEvent(тут сообщение) и UC переменная или скорее всего тест.

Удаляем UC и оставляем кавычки
GoodShadow вне форума Отправить сообщение для GoodShadow с помощью ICQ Отправить сообщение для GoodShadow с помощью Skype™ Ответить с цитированием
Сказали спасибо:
Ответ


Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 
Опции темы

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход

Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Помогите засунуть EnterWorld.java в ядро dgokill Lineage II 16 10.08.2010 01:33
Java SkyWard Lineage II 4 06.03.2010 10:18
Java virus Курилка / Yak floor 6 20.12.2008 03:50


© 2007–2022 «Форум администраторов игровых серверов»
Защита сайта от DDoS атак — StormWall
Работает на Булке неизвестной версии с переводом от zCarot
Текущее время: 15:00. Часовой пояс GMT +3.

Вверх