Guest User

Untitled

a guest
Dec 18th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.63 KB | None | 0 0
  1. /*
  2. * L2jFrozen Project - www.l2jfrozen.com
  3. *
  4. * This program is free software: you can redistribute it and/or modify it under
  5. * the terms of the GNU General Public License as published by the Free Software
  6. * Foundation, either version 3 of the License, or (at your option) any later
  7. * version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  12. * details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. package com.l2jfrozen.gameserver.network.clientpackets;
  18.  
  19. import java.io.File;
  20. import java.sql.Connection;
  21. import java.sql.PreparedStatement;
  22. import java.sql.ResultSet;
  23. import java.text.SimpleDateFormat;
  24. import java.util.Calendar;
  25. import java.util.Date;
  26. import java.util.regex.Matcher;
  27. import java.util.regex.Pattern;
  28. import java.util.regex.PatternSyntaxException;
  29.  
  30. import org.apache.log4j.Logger;
  31.  
  32. import com.l2jfrozen.BanManager;
  33. import com.l2jfrozen.Config;
  34. import com.l2jfrozen.crypt.nProtect;
  35. import com.l2jfrozen.crypt.nProtect.RestrictionType;
  36. import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager;
  37. import com.l2jfrozen.gameserver.controllers.GameTimeController;
  38. import com.l2jfrozen.gameserver.datatables.CharSchemesTable;
  39. import com.l2jfrozen.gameserver.datatables.GmListTable;
  40. import com.l2jfrozen.gameserver.datatables.SkillTable;
  41. import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable;
  42. import com.l2jfrozen.gameserver.datatables.sql.AdminCommandAccessRights;
  43. import com.l2jfrozen.gameserver.handler.custom.CustomWorldHandler;
  44. import com.l2jfrozen.gameserver.managers.CastleManager;
  45. import com.l2jfrozen.gameserver.managers.ClanHallManager;
  46. import com.l2jfrozen.gameserver.managers.CoupleManager;
  47. import com.l2jfrozen.gameserver.managers.CrownManager;
  48. import com.l2jfrozen.gameserver.managers.DimensionalRiftManager;
  49. import com.l2jfrozen.gameserver.managers.FortSiegeManager;
  50. import com.l2jfrozen.gameserver.managers.PetitionManager;
  51. import com.l2jfrozen.gameserver.managers.SiegeManager;
  52. import com.l2jfrozen.gameserver.model.Inventory;
  53. import com.l2jfrozen.gameserver.model.L2Character;
  54. import com.l2jfrozen.gameserver.model.L2Clan;
  55. import com.l2jfrozen.gameserver.model.L2Effect;
  56. import com.l2jfrozen.gameserver.model.L2Skill;
  57. import com.l2jfrozen.gameserver.model.L2World;
  58. import com.l2jfrozen.gameserver.model.actor.instance.L2ClassMasterInstance;
  59. import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
  60. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  61. import com.l2jfrozen.gameserver.model.base.ClassLevel;
  62. import com.l2jfrozen.gameserver.model.base.PlayerClass;
  63. import com.l2jfrozen.gameserver.model.entity.Announcements;
  64. import com.l2jfrozen.gameserver.model.entity.ClanHall;
  65. import com.l2jfrozen.gameserver.model.entity.Hero;
  66. import com.l2jfrozen.gameserver.model.entity.Wedding;
  67. import com.l2jfrozen.gameserver.model.entity.event.CTF;
  68. import com.l2jfrozen.gameserver.model.entity.event.DM;
  69. import com.l2jfrozen.gameserver.model.entity.event.L2Event;
  70. import com.l2jfrozen.gameserver.model.entity.event.TvT;
  71. import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  72. import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSigns;
  73. import com.l2jfrozen.gameserver.model.entity.siege.Castle;
  74. import com.l2jfrozen.gameserver.model.entity.siege.FortSiege;
  75. import com.l2jfrozen.gameserver.model.entity.siege.Siege;
  76. import com.l2jfrozen.gameserver.model.quest.Quest;
  77. import com.l2jfrozen.gameserver.model.quest.QuestState;
  78. import com.l2jfrozen.gameserver.network.Disconnection;
  79. import com.l2jfrozen.gameserver.network.SystemMessageId;
  80. import com.l2jfrozen.gameserver.network.serverpackets.ClientSetTime;
  81. import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  82. import com.l2jfrozen.gameserver.network.serverpackets.Die;
  83. import com.l2jfrozen.gameserver.network.serverpackets.Earthquake;
  84. import com.l2jfrozen.gameserver.network.serverpackets.EtcStatusUpdate;
  85. import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  86. import com.l2jfrozen.gameserver.network.serverpackets.ExStorageMaxCount;
  87. import com.l2jfrozen.gameserver.network.serverpackets.FriendList;
  88. import com.l2jfrozen.gameserver.network.serverpackets.HennaInfo;
  89. import com.l2jfrozen.gameserver.network.serverpackets.ItemList;
  90. import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
  91. import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  92. import com.l2jfrozen.gameserver.network.serverpackets.PledgeShowMemberListAll;
  93. import com.l2jfrozen.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
  94. import com.l2jfrozen.gameserver.network.serverpackets.PledgeSkillList;
  95. import com.l2jfrozen.gameserver.network.serverpackets.PledgeStatusChanged;
  96. import com.l2jfrozen.gameserver.network.serverpackets.QuestList;
  97. import com.l2jfrozen.gameserver.network.serverpackets.ShortCutInit;
  98. import com.l2jfrozen.gameserver.network.serverpackets.SignsSky;
  99. import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  100. import com.l2jfrozen.gameserver.network.serverpackets.UserInfo;
  101. import com.l2jfrozen.gameserver.powerpak.PowerPakConfig;
  102. import com.l2jfrozen.gameserver.thread.TaskPriority;
  103. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  104. import com.l2jfrozen.gameserver.util.Util;
  105. import com.l2jfrozen.util.database.L2DatabaseFactory;
  106.  
  107.  
  108. /**
  109. * Enter World Packet Handler
  110. */
  111. public class EnterWorld extends L2GameClientPacket
  112. {
  113. private static Logger LOGGER = Logger.getLogger(EnterWorld.class);
  114.  
  115. private final SimpleDateFormat fmt = new SimpleDateFormat("H:mm.");
  116. private long _daysleft;
  117. SimpleDateFormat df = new SimpleDateFormat("dd MM yyyy");
  118.  
  119. public TaskPriority getPriority()
  120. {
  121. return TaskPriority.PR_URGENT;
  122. }
  123.  
  124. @Override
  125. protected void readImpl()
  126. {
  127. // this is just a trigger packet. it has no content
  128. }
  129.  
  130. @Override
  131. protected void runImpl()
  132. {
  133. final L2PcInstance activeChar = getClient().getActiveChar();
  134.  
  135. if (activeChar == null)
  136. {
  137. LOGGER.warn("EnterWorld failed! activeChar is null...");
  138. getClient().closeNow();
  139. return;
  140. }
  141.  
  142. // Set lock at login
  143. activeChar.setLocked(true);
  144.  
  145. // Register in flood protector
  146. // FloodProtector.getInstance().registerNewPlayer(activeChar.getObjectId());
  147.  
  148. if (L2World.getInstance().findObject(activeChar.getObjectId()) != null)
  149. {
  150. if (Config.DEBUG)
  151. {
  152. LOGGER.warn("DEBUG " + getType() + ": User already exist in OID map! User " + activeChar.getName() + " is character clone");
  153. // activeChar.closeNetConnection(); // Do nothing?
  154. }
  155. }
  156.  
  157. if (!activeChar.isGM() && !activeChar.isDonator() && Config.CHECK_NAME_ON_LOGIN)
  158. {
  159. if (activeChar.getName().length() < 3 || activeChar.getName().length() > 16 || !Util.isAlphaNumeric(activeChar.getName()) || !isValidName(activeChar.getName()))
  160. {
  161. LOGGER.warn("Charname: " + activeChar.getName() + " is invalid. EnterWorld failed.");
  162. getClient().closeNow();
  163. return;
  164. }
  165. }
  166.  
  167. // RnP (Del Donateriu kad nedingtu po rr spalva)
  168. if (activeChar.isdonator())
  169. {
  170. if (activeChar.isdonator())
  171. activeChar.getAppearance().setNameColor(Config.DONATOR_NAME_COLOR);
  172. if (activeChar.isdonator())
  173. activeChar.getAppearance().setTitleColor(Config.DONATOR_TITLE_COLOR);
  174. }
  175.  
  176. // Set online status
  177. activeChar.setOnlineStatus(true);
  178.  
  179. activeChar.setRunning(); // running is default
  180. activeChar.standUp(); // standing is default
  181.  
  182. activeChar.broadcastKarma(); // include UserInfo
  183.  
  184. // Engage and notify Partner
  185. if (Config.L2JMOD_ALLOW_WEDDING)
  186. {
  187. engage(activeChar);
  188. notifyPartner(activeChar, activeChar.getPartnerId());
  189. announceTopPk(activeChar);
  190. announceTopPvp(activeChar);
  191. }
  192.  
  193. EnterGM(activeChar);
  194.  
  195. Quest.playerEnter(activeChar);
  196. activeChar.sendPacket(new QuestList());
  197.  
  198. if (Config.PLAYER_SPAWN_PROTECTION > 0)
  199. activeChar.setProtection(true);
  200.  
  201. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  202.  
  203. if (SevenSigns.getInstance().isSealValidationPeriod())
  204. sendPacket(new SignsSky());
  205.  
  206. // Buff and Status icons
  207. if (Config.STORE_SKILL_COOLTIME)
  208. {
  209. activeChar.restoreEffects();
  210. }
  211.  
  212. if(BanManager.ips.contains(activeChar.getIP()))
  213. {
  214. sendPacket(new CreatureSay(activeChar.getObjectId(), Say2.CRITICAL_ANNOUNCE, "SERVER:", "You have been banned from this server. Have a nice day! :)"));
  215. sendPacket(new ExShowScreenMessage("You have been banned from this server. Have a nice day! :)", 60 * 60 * 1000));
  216. try{
  217. Thread.sleep(1500);
  218. }catch(Exception e){}
  219. getClient().closeNow();
  220. return;
  221. }
  222. activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  223.  
  224. final L2Effect[] effects = activeChar.getAllEffects();
  225.  
  226. if (effects != null)
  227. {
  228. for (final L2Effect e : effects)
  229. {
  230. if (e.getEffectType() == L2Effect.EffectType.HEAL_OVER_TIME)
  231. {
  232. activeChar.stopEffects(L2Effect.EffectType.HEAL_OVER_TIME);
  233. activeChar.removeEffect(e);
  234. }
  235. if (e.getEffectType() == L2Effect.EffectType.COMBAT_POINT_HEAL_OVER_TIME)
  236. {
  237. activeChar.stopEffects(L2Effect.EffectType.COMBAT_POINT_HEAL_OVER_TIME);
  238. activeChar.removeEffect(e);
  239. }
  240. }
  241. }
  242.  
  243. // Apply augmentation boni for equipped items
  244. for (final L2ItemInstance temp : activeChar.getInventory().getAugmentedItems())
  245. if (temp != null && temp.isEquipped())
  246. temp.getAugmentation().applyBoni(activeChar);
  247.  
  248. // Apply death penalty
  249. activeChar.restoreDeathPenaltyBuffLevel();
  250.  
  251. if (L2Event.active && L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.isOnEvent(activeChar))
  252. L2Event.restoreChar(activeChar);
  253. else if (L2Event.connectionLossData.containsKey(activeChar.getName()))
  254. L2Event.restoreAndTeleChar(activeChar);
  255.  
  256. // SECURE FIX - Anti Overenchant Cheat!!
  257. if (Config.MAX_ITEM_ENCHANT_KICK > 0)
  258. {
  259. for (final L2ItemInstance i : activeChar.getInventory().getItems())
  260. {
  261. if (!activeChar.isGM())
  262. {
  263. if (i.isEquipable())
  264. {
  265. if (i.getEnchantLevel() > Config.MAX_ITEM_ENCHANT_KICK)
  266. {
  267. // Delete Item Over enchanted
  268. activeChar.getInventory().destroyItem(null, i, activeChar, null);
  269. // Message to Player
  270. activeChar.sendMessage("[Server]: You have over enchanted items you will be kicked from server!");
  271. activeChar.sendMessage("[Server]: Respect our server rules.");
  272. // Message with screen
  273. sendPacket(new ExShowScreenMessage(" You have an over enchanted item, you will be kicked from server! ", 6000));
  274. // Punishment e LOGGER in audit
  275. Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " has Overenchanted item! Kicked! ", Config.DEFAULT_PUNISH);
  276. // Logger in console
  277. LOGGER.info("#### ATTENTION ####");
  278. LOGGER.info(i + " item has been removed from " + activeChar);
  279. }
  280.  
  281. }
  282. }
  283. }
  284. }
  285.  
  286. // Restores custom status
  287. activeChar.restoreCustomStatus();
  288.  
  289. ColorSystem(activeChar);
  290.  
  291. // Expand Skill
  292. final ExStorageMaxCount esmc = new ExStorageMaxCount(activeChar);
  293. activeChar.sendPacket(esmc);
  294.  
  295. activeChar.getMacroses().sendUpdate();
  296.  
  297. // Send packets info
  298. sendPacket(new ClientSetTime()); // SetClientTime
  299. sendPacket(new UserInfo(activeChar)); //
  300. sendPacket(new HennaInfo(activeChar));
  301. sendPacket(new FriendList(activeChar));
  302. sendPacket(new ItemList(activeChar, false));
  303. sendPacket(new ShortCutInit(activeChar));
  304.  
  305. // Reload inventory to give SA skill
  306. activeChar.getInventory().reloadEquippedItems();
  307.  
  308. // Welcome to Lineage II
  309. sendPacket(new SystemMessage(SystemMessageId.WELCOME_TO_LINEAGE));
  310.  
  311. // Credits to L2jfrozen
  312. activeChar.sendMessage("This server uses L2JFrozen, a project founded by L2Chef and");
  313. activeChar.sendMessage("developed by the L2JFrozen Dev Team at l2jfrozen.com");
  314.  
  315. SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
  316. Announcements.getInstance().showAnnouncements(activeChar);
  317.  
  318. loadTutorial(activeChar);
  319.  
  320. // Check for crowns
  321. CrownManager.getInstance().checkCrowns(activeChar);
  322.  
  323. // Check player skills
  324. if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  325. activeChar.checkAllowedSkills();
  326.  
  327. PetitionManager.getInstance().checkPetitionMessages(activeChar);
  328.  
  329. // Send user info again .. just like the real client
  330. // sendPacket(ui);
  331.  
  332. if (activeChar.getClanId() != 0 && activeChar.getClan() != null)
  333. {
  334. sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
  335. sendPacket(new PledgeStatusChanged(activeChar.getClan()));
  336. }
  337.  
  338. if (activeChar.isAlikeDead())
  339. sendPacket(new Die(activeChar)); // No broadcast needed since the player will already spawn dead to others
  340.  
  341. if (Config.ALLOW_WATER)
  342. activeChar.checkWaterState();
  343.  
  344. if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()))
  345. activeChar.setHero(true);
  346.  
  347. setPledgeClass(activeChar);
  348.  
  349. for (final String name : activeChar.getFriendList())
  350. {
  351. final L2PcInstance friend = L2World.getInstance().getPlayer(name);
  352.  
  353. if (friend != null) // friend logged in.
  354. friend.sendPacket(new SystemMessage(SystemMessageId.FRIEND_S1_HAS_LOGGED_IN).addString(activeChar.getName()));
  355. }
  356.  
  357. notifyClanMembers(activeChar);
  358. notifySponsorOrApprentice(activeChar);
  359.  
  360. activeChar.setTarget(activeChar);
  361.  
  362. activeChar.onPlayerEnter();
  363.  
  364. if (Config.PCB_ENABLE)
  365. activeChar.showPcBangWindow();
  366.  
  367. if (Config.ANNOUNCE_CASTLE_LORDS)
  368. notifyCastleOwner(activeChar);
  369.  
  370. if (Olympiad.getInstance().playerInStadia(activeChar))
  371. {
  372. activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  373. activeChar.sendMessage("You have been teleported to the nearest town due to you being in an Olympiad Stadium");
  374. }
  375.  
  376. if (DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false))
  377. DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);
  378.  
  379. if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
  380. activeChar.sendPacket(new SystemMessage(SystemMessageId.CLAN_MEMBERSHIP_TERMINATED));
  381.  
  382. if (activeChar.getClan() != null)
  383. {
  384. activeChar.sendPacket(new PledgeSkillList(activeChar.getClan()));
  385.  
  386. for (final Siege siege : SiegeManager.getInstance().getSieges())
  387. {
  388. if (!siege.getIsInProgress())
  389. continue;
  390.  
  391. if (siege.checkIsAttacker(activeChar.getClan()))
  392. {
  393. activeChar.setSiegeState((byte) 1);
  394. break;
  395. }
  396. else if (siege.checkIsDefender(activeChar.getClan()))
  397. {
  398. activeChar.setSiegeState((byte) 2);
  399. break;
  400. }
  401. }
  402.  
  403. for (final FortSiege fortsiege : FortSiegeManager.getInstance().getSieges())
  404. {
  405. if (!fortsiege.getIsInProgress())
  406. continue;
  407.  
  408. if (fortsiege.checkIsAttacker(activeChar.getClan()))
  409. {
  410. activeChar.setSiegeState((byte) 1);
  411. break;
  412. }
  413. else if (fortsiege.checkIsDefender(activeChar.getClan()))
  414. {
  415. activeChar.setSiegeState((byte) 2);
  416. break;
  417. }
  418. }
  419.  
  420. // Add message at connexion if clanHall not paid. Possibly this is custom...
  421. final ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
  422.  
  423. if (clanHall != null)
  424. if (!clanHall.getPaid())
  425. activeChar.sendPacket(new SystemMessage(SystemMessageId.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_MAKE_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW));
  426. }
  427.  
  428. if (!activeChar.isGM() && activeChar.getSiegeState() < 2 && activeChar.isInsideZone(L2Character.ZONE_SIEGE))
  429. {
  430. // Attacker or spectator logging in to a siege zone. Actually should be checked for inside castle only?
  431. activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  432. activeChar.sendMessage("You have been teleported to the nearest town due to you being in siege zone");
  433. }
  434.  
  435. RegionBBSManager.getInstance().changeCommunityBoard();
  436. CustomWorldHandler.getInstance().enterWorld(activeChar);
  437.  
  438. if (TvT._savePlayers.contains(activeChar.getName()))
  439. TvT.addDisconnectedPlayer(activeChar);
  440.  
  441. if (CTF._savePlayers.contains(activeChar.getName()))
  442. CTF.addDisconnectedPlayer(activeChar);
  443.  
  444. if (DM._savePlayers.contains(activeChar.getName()))
  445. DM.addDisconnectedPlayer(activeChar);
  446.  
  447. // Means that it's not ok multiBox situation, so logout
  448. if (!activeChar.checkMultiBox())
  449. {
  450. activeChar.sendMessage("I'm sorry, but multibox is not allowed here.");
  451. activeChar.logout();
  452. }
  453.  
  454. Hellows(activeChar);
  455.  
  456. if (Config.ALLOW_CLASS_MASTERS && Config.ALLOW_REMOTE_CLASS_MASTERS)
  457. {
  458. final L2ClassMasterInstance master_instance = L2ClassMasterInstance.getInstance();
  459.  
  460. if (master_instance != null)
  461. {
  462.  
  463. final ClassLevel lvlnow = PlayerClass.values()[activeChar.getClassId().getId()].getLevel();
  464.  
  465. if (activeChar.getLevel() >= 20 && lvlnow == ClassLevel.First)
  466. L2ClassMasterInstance.getInstance().onAction(activeChar);
  467. else if (activeChar.getLevel() >= 40 && lvlnow == ClassLevel.Second)
  468. L2ClassMasterInstance.getInstance().onAction(activeChar);
  469. else if (activeChar.getLevel() >= 76 && lvlnow == ClassLevel.Third)
  470. L2ClassMasterInstance.getInstance().onAction(activeChar);
  471.  
  472. }
  473. else
  474. {
  475.  
  476. LOGGER.info("Attention: Remote ClassMaster is Enabled, but not inserted into DataBase. Remember to install 31288 Custom_Npc ..");
  477.  
  478. }
  479. }
  480.  
  481. // Apply night/day bonus on skill Shadow Sense
  482. if (activeChar.getRace().ordinal() == 2)
  483. {
  484. final L2Skill skill = SkillTable.getInstance().getInfo(294, 1);
  485. if (skill != null && activeChar.getSkillLevel(294) == 1)
  486. {
  487. if (GameTimeController.getInstance().isNowNight())
  488. {
  489. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.NIGHT_EFFECT_APPLIES);
  490. sm.addSkillName(294);
  491. sendPacket(sm);
  492. }
  493. else
  494. {
  495. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.DAY_EFFECT_DISAPPEARS);
  496. sm.addSkillName(294);
  497. sendPacket(sm);
  498. }
  499. }
  500. }
  501.  
  502. // NPCBuffer
  503. if (PowerPakConfig.BUFFER_ENABLED)
  504. CharSchemesTable.getInstance().onPlayerLogin(activeChar.getObjectId());
  505.  
  506. if (!nProtect.getInstance().checkRestriction(activeChar, RestrictionType.RESTRICT_ENTER))
  507. {
  508. activeChar.setIsImobilised(true);
  509. activeChar.disableAllSkills();
  510. ThreadPoolManager.getInstance().scheduleGeneral(new Disconnection(activeChar), 20000);
  511. }
  512.  
  513. // Elrokian Trap like L2OFF
  514. final L2ItemInstance rhand = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  515. if (rhand != null && rhand.getItemId() == 8763)
  516. {
  517. activeChar.addSkill(SkillTable.getInstance().getInfo(3626, 1));
  518. activeChar.addSkill(SkillTable.getInstance().getInfo(3627, 1));
  519. activeChar.addSkill(SkillTable.getInstance().getInfo(3628, 1));
  520. }
  521. else
  522. {
  523. activeChar.removeSkill(3626, true);
  524. activeChar.removeSkill(3627, true);
  525. activeChar.removeSkill(3628, true);
  526. }
  527.  
  528. // If it's a Beta server all players got GM SPEED skill for better testing
  529. if (Config.BETASERVER)
  530. {
  531. activeChar.addSkill(SkillTable.getInstance().getInfo(7029, 4), true);
  532. activeChar.sendMessage("Server is on Beta mode. Skill Gm Haste 4 added for better testing.");
  533. }
  534.  
  535. // Send all skills to char
  536. activeChar.sendSkillList();
  537.  
  538. // Close lock at login
  539. activeChar.setLocked(false);
  540. }
  541.  
  542. private boolean isValidName(final String text)
  543. {
  544. boolean result = true;
  545. final String test = text;
  546. Pattern pattern;
  547.  
  548. try
  549. {
  550. pattern = Pattern.compile(Config.CNAME_TEMPLATE);
  551. }
  552. catch (final PatternSyntaxException e) // case of illegal pattern
  553. {
  554. if (Config.ENABLE_ALL_EXCEPTIONS)
  555. e.printStackTrace();
  556.  
  557. LOGGER.warn("ERROR " + getType() + ": Character name pattern of config is wrong!");
  558. pattern = Pattern.compile(".*");
  559. }
  560.  
  561. final Matcher regexp = pattern.matcher(test);
  562. if (!regexp.matches())
  563. result = false;
  564.  
  565. return result;
  566. }
  567.  
  568. private void EnterGM(final L2PcInstance activeChar)
  569. {
  570. if (activeChar.isGM())
  571. {
  572. if (Config.GM_SPECIAL_EFFECT)
  573. activeChar.broadcastPacket(new Earthquake(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 50, 4));
  574.  
  575. if (Config.SHOW_GM_LOGIN)
  576. Announcements.getInstance().announceToAll("GM " + activeChar.getName() + " has logged on.");
  577.  
  578. if (Config.GM_STARTUP_INVULNERABLE && AdminCommandAccessRights.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
  579. activeChar.setIsInvul(true);
  580.  
  581. if (Config.GM_STARTUP_INVISIBLE && AdminCommandAccessRights.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
  582. activeChar.getAppearance().setInvisible();
  583.  
  584. if (Config.GM_STARTUP_SILENCE && AdminCommandAccessRights.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
  585. activeChar.setMessageRefusal(true);
  586.  
  587. if (Config.GM_STARTUP_AUTO_LIST && AdminCommandAccessRights.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
  588. GmListTable.getInstance().addGm(activeChar, false);
  589. else
  590. GmListTable.getInstance().addGm(activeChar, true);
  591.  
  592. if (Config.MASTERACCESS_NAME_COLOR_ENABLED)
  593. activeChar.getAppearance().setNameColor(Config.MASTERACCESS_NAME_COLOR);
  594.  
  595. if (Config.MASTERACCESS_TITLE_COLOR_ENABLED)
  596. activeChar.getAppearance().setTitleColor(Config.MASTERACCESS_TITLE_COLOR);
  597. }
  598. }
  599.  
  600. private void Hellows(final L2PcInstance activeChar)
  601. {
  602. if (Config.ALT_SERVER_NAME_ENABLED)
  603. sendPacket(new SystemMessage(SystemMessageId.S1_S2).addString("Welcome to " + Config.ALT_Server_Name));
  604.  
  605. if (Config.ONLINE_PLAYERS_ON_LOGIN)
  606. sendPacket(new SystemMessage(SystemMessageId.S1_S2).addString("There are " + L2World.getInstance().getAllPlayers().size() + " players online."));
  607.  
  608. if (activeChar.getFirstLog() && Config.NEW_PLAYER_EFFECT)
  609. {
  610. final L2Skill skill = SkillTable.getInstance().getInfo(2025, 1);
  611. if (skill != null)
  612. {
  613. final MagicSkillUser MSU = new MagicSkillUser(activeChar, activeChar, 2025, 1, 1, 0);
  614. activeChar.sendPacket(MSU);
  615. activeChar.broadcastPacket(MSU);
  616. activeChar.useMagic(skill, false, false);
  617. }
  618. activeChar.setFirstLog(false);
  619. activeChar.updateFirstLog();
  620. }
  621.  
  622. if (Config.WELCOME_HTM && isValidName(activeChar.getName()))
  623. {
  624. final String Welcome_Path = "data/html/welcome.htm";
  625. final File mainText = new File(Config.DATAPACK_ROOT, Welcome_Path);
  626. if (mainText.exists())
  627. {
  628. final NpcHtmlMessage html = new NpcHtmlMessage(1);
  629. html.setFile(Welcome_Path);
  630. html.replace("%name%", activeChar.getName());
  631. sendPacket(html);
  632. }
  633. }
  634.  
  635. if ((activeChar.getClan() != null) && activeChar.getClan().isNoticeEnabled())
  636. {
  637. final String clanNotice = "data/html/clanNotice.htm";
  638. final File mainText = new File(Config.DATAPACK_ROOT, clanNotice);
  639. if (mainText.exists())
  640. {
  641. final NpcHtmlMessage html = new NpcHtmlMessage(1);
  642. html.setFile(clanNotice);
  643. html.replace("%clan_name%", activeChar.getClan().getName());
  644. html.replace("%notice_text%", activeChar.getClan().getNotice().replaceAll("\r\n", "<br>"));
  645. sendPacket(html);
  646. }
  647. }
  648.  
  649. if (Config.PM_MESSAGE_ON_START)
  650. {
  651. activeChar.sendPacket(new CreatureSay(2, Say2.HERO_VOICE, Config.PM_TEXT1, Config.PM_SERVER_NAME));
  652. activeChar.sendPacket(new CreatureSay(15, Say2.PARTYROOM_COMMANDER, activeChar.getName(), Config.PM_TEXT2));
  653. }
  654.  
  655. if (Config.SERVER_TIME_ON_START)
  656. activeChar.sendMessage("SVR time is " + fmt.format(new Date(System.currentTimeMillis())));
  657. }
  658.  
  659. private void ColorSystem(final L2PcInstance activeChar)
  660. {
  661. // Color System checks - Start
  662. // Check if the custom PvP and PK color systems are enabled and if so check the character's counters
  663. // and apply any color changes that must be done. Thankz Kidzor
  664. /** KidZor: Ammount 1 **/
  665. if (activeChar.getPvpKills() >= Config.PVP_AMOUNT1 && Config.PVP_COLOR_SYSTEM_ENABLED)
  666. activeChar.updatePvPColor(activeChar.getPvpKills());
  667. if (activeChar.getPkKills() >= Config.PK_AMOUNT1 && Config.PK_COLOR_SYSTEM_ENABLED)
  668. activeChar.updatePkColor(activeChar.getPkKills());
  669.  
  670. /** KidZor: Ammount 2 **/
  671. if (activeChar.getPvpKills() >= Config.PVP_AMOUNT2 && Config.PVP_COLOR_SYSTEM_ENABLED)
  672. activeChar.updatePvPColor(activeChar.getPvpKills());
  673. if (activeChar.getPkKills() >= Config.PK_AMOUNT2 && Config.PK_COLOR_SYSTEM_ENABLED)
  674. activeChar.updatePkColor(activeChar.getPkKills());
  675.  
  676. /** KidZor: Ammount 3 **/
  677. if (activeChar.getPvpKills() >= Config.PVP_AMOUNT3 && Config.PVP_COLOR_SYSTEM_ENABLED)
  678. activeChar.updatePvPColor(activeChar.getPvpKills());
  679. if (activeChar.getPkKills() >= Config.PK_AMOUNT3 && Config.PK_COLOR_SYSTEM_ENABLED)
  680. activeChar.updatePkColor(activeChar.getPkKills());
  681.  
  682. /** KidZor: Ammount 4 **/
  683. if (activeChar.getPvpKills() >= Config.PVP_AMOUNT4 && Config.PVP_COLOR_SYSTEM_ENABLED)
  684. activeChar.updatePvPColor(activeChar.getPvpKills());
  685. if (activeChar.getPkKills() >= Config.PK_AMOUNT4 && Config.PK_COLOR_SYSTEM_ENABLED)
  686. activeChar.updatePkColor(activeChar.getPkKills());
  687.  
  688. /** KidZor: Ammount 5 **/
  689. if (activeChar.getPvpKills() >= Config.PVP_AMOUNT5 && Config.PVP_COLOR_SYSTEM_ENABLED)
  690. activeChar.updatePvPColor(activeChar.getPvpKills());
  691. if (activeChar.getPkKills() >= Config.PK_AMOUNT5 && Config.PK_COLOR_SYSTEM_ENABLED)
  692. activeChar.updatePkColor(activeChar.getPkKills());
  693. // Color System checks - End
  694.  
  695. // Apply color settings to clan leader when entering
  696. if (activeChar.getClan() != null && activeChar.isClanLeader() && Config.CLAN_LEADER_COLOR_ENABLED && activeChar.getClan().getLevel() >= Config.CLAN_LEADER_COLOR_CLAN_LEVEL)
  697. {
  698. if (Config.CLAN_LEADER_COLORED == 1)
  699. activeChar.getAppearance().setNameColor(Config.CLAN_LEADER_COLOR);
  700. else
  701. activeChar.getAppearance().setTitleColor(Config.CLAN_LEADER_COLOR);
  702. }
  703.  
  704. if (Config.ALLOW_AIO_NCOLOR && activeChar.isAio())
  705. activeChar.getAppearance().setNameColor(Config.AIO_NCOLOR);
  706.  
  707. if (Config.ALLOW_AIO_TCOLOR && activeChar.isAio())
  708. activeChar.getAppearance().setTitleColor(Config.AIO_TCOLOR);
  709.  
  710. if (activeChar.isAio())
  711. onEnterAio(activeChar);
  712.  
  713. activeChar.updateNameTitleColor();
  714.  
  715. sendPacket(new UserInfo(activeChar));
  716. sendPacket(new HennaInfo(activeChar));
  717. sendPacket(new FriendList(activeChar));
  718. sendPacket(new ItemList(activeChar, false));
  719. sendPacket(new ShortCutInit(activeChar));
  720. activeChar.broadcastUserInfo();
  721. activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  722. }
  723.  
  724. private void onEnterAio(final L2PcInstance activeChar)
  725. {
  726. final long now = Calendar.getInstance().getTimeInMillis();
  727. final long endDay = activeChar.getAioEndTime();
  728.  
  729. if (now > endDay)
  730. {
  731. activeChar.setAio(false);
  732. activeChar.setAioEndTime(0);
  733. activeChar.lostAioSkills();
  734. activeChar.sendMessage("[Aio System]: Removed your Aio stats... period ends.");
  735. }
  736. else
  737. {
  738. final Date dt = new Date(endDay);
  739. _daysleft = (endDay - now) / 86400000;
  740. if (_daysleft > 30)
  741. activeChar.sendMessage("[Aio System]: Aio period ends in " + df.format(dt) + ". enjoy the Game.");
  742. else if (_daysleft > 0)
  743. activeChar.sendMessage("[Aio System]: Left " + (int) _daysleft + " for Aio period ends.");
  744. else if (_daysleft < 1)
  745. {
  746. final long hour = (endDay - now) / 3600000;
  747. activeChar.sendMessage("[Aio System]: Left " + (int) hour + " hours to Aio period ends.");
  748. }
  749. }
  750. }
  751.  
  752. /**
  753. * @param cha
  754. */
  755. private void engage(final L2PcInstance cha)
  756. {
  757. final int _chaid = cha.getObjectId();
  758.  
  759. for (final Wedding cl : CoupleManager.getInstance().getCouples())
  760. {
  761. if (cl.getPlayer1Id() == _chaid || cl.getPlayer2Id() == _chaid)
  762. {
  763. if (cl.getMaried())
  764. {
  765. cha.setMarried(true);
  766. cha.setmarriedType(cl.getType());
  767. }
  768.  
  769. cha.setCoupleId(cl.getId());
  770.  
  771. if (cl.getPlayer1Id() == _chaid)
  772. cha.setPartnerId(cl.getPlayer2Id());
  773. else
  774. cha.setPartnerId(cl.getPlayer1Id());
  775. }
  776. }
  777. }
  778.  
  779. /**
  780. * @param cha
  781. * @param partnerId
  782. */
  783. private void notifyPartner(final L2PcInstance cha, final int partnerId)
  784. {
  785. if (cha.getPartnerId() != 0)
  786. {
  787. L2PcInstance partner = null;
  788.  
  789. if (L2World.getInstance().findObject(cha.getPartnerId()) instanceof L2PcInstance)
  790. partner = (L2PcInstance) L2World.getInstance().findObject(cha.getPartnerId());
  791.  
  792. if (partner != null)
  793. partner.sendMessage("Your partner has logged in");
  794. }
  795. }
  796.  
  797. private void notifyClanMembers(final L2PcInstance activeChar)
  798. {
  799. final L2Clan clan = activeChar.getClan();
  800. if (clan != null)
  801. {
  802. clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
  803. clan.broadcastToOtherOnlineMembers(new SystemMessage(SystemMessageId.CLAN_MEMBER_S1_LOGGED_IN).addString(activeChar.getName()), activeChar);
  804. clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
  805. }
  806. }
  807.  
  808. /**
  809. * @param activeChar
  810. */
  811. private void notifySponsorOrApprentice(final L2PcInstance activeChar)
  812. {
  813. if (activeChar.getSponsor() != 0)
  814. {
  815. final L2PcInstance sponsor = (L2PcInstance) L2World.getInstance().findObject(activeChar.getSponsor());
  816. if (sponsor != null)
  817. sponsor.sendPacket(new SystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN).addString(activeChar.getName()));
  818. }
  819. else if (activeChar.getApprentice() != 0)
  820. {
  821. final L2PcInstance apprentice = (L2PcInstance) L2World.getInstance().findObject(activeChar.getApprentice());
  822. if (apprentice != null)
  823. apprentice.sendPacket(new SystemMessage(SystemMessageId.YOUR_SPONSOR_S1_HAS_LOGGED_IN).addString(activeChar.getName()));
  824. }
  825. }
  826.  
  827. private void loadTutorial(final L2PcInstance player)
  828. {
  829. final QuestState qs = player.getQuestState("255_Tutorial");
  830. if (qs != null)
  831. qs.getQuest().notifyEvent("UC", null, player);
  832. }
  833.  
  834. private void setPledgeClass(final L2PcInstance activeChar)
  835. {
  836. int pledgeClass = 0;
  837.  
  838. if (activeChar.getClan() != null)
  839. pledgeClass = activeChar.getClan().getClanMember(activeChar.getObjectId()).calculatePledgeClass(activeChar);
  840.  
  841. if (activeChar.isNoble() && pledgeClass < 5)
  842. pledgeClass = 5;
  843.  
  844. if (activeChar.isHero())
  845. pledgeClass = 8;
  846.  
  847. activeChar.setPledgeClass(pledgeClass);
  848. }
  849.  
  850. private void notifyCastleOwner(final L2PcInstance activeChar)
  851. {
  852. final L2Clan clan = activeChar.getClan();
  853. if (clan != null)
  854. {
  855. if (clan.getHasCastle() > 0)
  856. {
  857. final Castle castle = CastleManager.getInstance().getCastleById(clan.getHasCastle());
  858. if ((castle != null) && (activeChar.getObjectId() == clan.getLeaderId()))
  859. Announcements.getInstance().announceToAll("Lord " + activeChar.getName() + " Ruler Of " + castle.getName() + " Castle is now Online!");
  860. }
  861. }
  862. }
  863.  
  864. private static void announceTopPvp(L2PcInstance activeChar)
  865. {
  866. String name = null;
  867. String text1 = "Top PvP Player: ";
  868. PreparedStatement statement = null;
  869. try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  870. {
  871. statement = con.prepareStatement("SELECT char_name,pvpkills FROM characters WHERE accesslevel=0 ORDER BY pvpkills DESC LIMIT 1");
  872. ResultSet rset = statement.executeQuery();
  873. while (rset.next())
  874. {
  875. name = rset.getString("char_name");
  876. if (activeChar.getName().equals(name))
  877. Announcements.customAnnounce(text1,name +" Is Now Online!");
  878. }
  879. rset.close();
  880. statement.close();
  881. }
  882. catch (Exception e){}
  883. }
  884. // RnP (del kad announcti (TOP PK /PVP )
  885. private static void announceTopPk(L2PcInstance activeChar)
  886. {
  887. String name = null;
  888. String text1 = "Top Pk Player: ";
  889. PreparedStatement statement = null;
  890. try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  891. {
  892. statement = con.prepareStatement("SELECT char_name,pkkills FROM characters WHERE accesslevel=0 ORDER BY pkkills DESC LIMIT 1");
  893. ResultSet rset = statement.executeQuery();
  894. while (rset.next())
  895. {
  896. name = rset.getString("char_name");
  897. if (activeChar.getName().equals(name))
  898. Announcements.customAnnounce(text1,name +" Is Now Online!");
  899. }
  900. rset.close();
  901. statement.close();
  902. }
  903. catch (Exception e){}
  904. }
  905. @Override
  906. public String getType()
  907. {
  908. return "[C] 03 EnterWorld";
  909. }
  910. }
Add Comment
Please, Sign In to add comment