@Override public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) { if (player.isInParty()) { for (L2PcInstance partyMember : player.getParty().getPartyMembers()) { if (partyMember != null) testKetraDemote(partyMember); } } else testKetraDemote(player); return null; }
@Override protected void runImpl() { final L2PcInstance _activeChar = getClient().getActiveChar(); if (_activeChar == null) return; final PartyMatchRoom _room = PartyMatchRoomList.getInstance().getRoom(_roomid); if (_room == null) return; if ((_activeChar.isInParty() && _room.getOwner().isInParty()) && (_activeChar.getParty().getPartyLeaderOID() == _room.getOwner().getParty().getPartyLeaderOID())) { // If user is in party with Room Owner is not removed from Room } else { _room.deleteMember(_activeChar); _activeChar.setPartyRoom(0); _activeChar.broadcastUserInfo(); _activeChar.sendPacket(ExClosePartyRoom.STATIC_PACKET); _activeChar.sendPacket(SystemMessageId.PARTY_ROOM_EXITED); } }
@Override public boolean useAdminCommand(String command, L2PcInstance activeChar) { // runmod if (command.equals("admin_runmod") || command.equals("admin_instant_move")) activeChar.setTeleMode(1); if (command.equals("admin_runmod tele")) activeChar.setTeleMode(2); if (command.equals("admin_runmod norm")) activeChar.setTeleMode(0); // teleport via panels if (command.equals("admin_tele")) AdminHelpPage.showHelpPage(activeChar, "teleports.htm"); if (command.equals("admin_tele_areas")) AdminHelpPage.showHelpPage(activeChar, "tele/other.htm"); // recalls / goto types if (command.startsWith("admin_goto") || command.startsWith("admin_teleportto")) { StringTokenizer st = new StringTokenizer(command); if (st.countTokens() > 1) { st.nextToken(); String plyr = st.nextToken(); L2PcInstance player = L2World.getInstance().getPlayer(plyr); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } teleportToCharacter(activeChar, player); } } else if (command.startsWith("admin_recall ")) { try { String targetName = command.substring(13); L2PcInstance player = L2World.getInstance().getPlayer(targetName); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ()); } catch (StringIndexOutOfBoundsException e) { } } else if (command.startsWith("admin_recall_party")) { try { String targetName = command.substring(19); L2PcInstance player = L2World.getInstance().getPlayer(targetName); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } if (player.isInParty()) { for (L2PcInstance pm : player.getParty().getPartyMembers()) teleportCharacter(pm, activeChar.getX(), activeChar.getY(), activeChar.getZ()); activeChar.sendMessage("You recall " + player.getName() + "'s party."); } else { activeChar.sendMessage("You recall " + player.getName() + ", but he isn't in a party."); teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ()); } } catch (StringIndexOutOfBoundsException e) { } } else if (command.startsWith("admin_recall_clan")) { try { String targetName = command.substring(18); L2PcInstance player = L2World.getInstance().getPlayer(targetName); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } L2Clan clan = player.getClan(); if (clan != null) { for (L2PcInstance member : clan.getOnlineMembers()) teleportCharacter(member, activeChar.getX(), activeChar.getY(), activeChar.getZ()); activeChar.sendMessage("You recall " + player.getName() + "'s clan."); } else { activeChar.sendMessage( "You recall " + player.getName() + ", but he isn't a clan member."); teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ()); } } catch (StringIndexOutOfBoundsException e) { } } else if (command.startsWith("admin_move_to")) { try { String val = command.substring(14); teleportTo(activeChar, val); } catch (Exception e) { // Case of empty or missing coordinates AdminHelpPage.showHelpPage(activeChar, "teleports.htm"); } } else if (command.startsWith("admin_sendhome")) { StringTokenizer st = new StringTokenizer(command); if (st.countTokens() > 1) { st.nextToken(); String plyr = st.nextToken(); L2PcInstance player = L2World.getInstance().getPlayer(plyr); if (player == null) { activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET); return false; } sendHome(player); } else { L2Object target = activeChar.getTarget(); L2PcInstance player = null; // if target isn't a player, select yourself as target if (target instanceof L2PcInstance) player = (L2PcInstance) target; else player = activeChar; sendHome(player); } } return true; }
public boolean useAdminCommand(String command, L2PcInstance activeChar) { if (command.equals("admin_current_player")) { showCharacterInfo(activeChar, null); } else if ((command.startsWith("admin_character_list")) || (command.startsWith("admin_character_info"))) { try { String val = command.substring(21); L2PcInstance target = L2World.getInstance().getPlayer(val); if (target != null) showCharacterInfo(activeChar, target); else activeChar.sendPacket(new SystemMessage(SystemMessageId.CHARACTER_DOES_NOT_EXIST)); } catch (StringIndexOutOfBoundsException e) { activeChar.sendMessage(385); } } else if (command.startsWith("admin_show_characters")) { try { String val = command.substring(22); int page = Integer.parseInt(val); listCharacters(activeChar, page); } catch (StringIndexOutOfBoundsException e) { // Case of empty page number activeChar.sendMessage(421); } } else if (command.startsWith("admin_find_character")) { try { String val = command.substring(21); findCharacter(activeChar, val); } catch (StringIndexOutOfBoundsException e) { // Case of empty character name activeChar.sendMessage(392); listCharacters(activeChar, 0); } } else if (command.startsWith("admin_find_ip")) { try { String val = command.substring(14); findCharactersPerIp(activeChar, val); } catch (Exception e) { // Case of empty or malformed IP number activeChar.sendMessage(393); listCharacters(activeChar, 0); } } else if (command.startsWith("admin_find_account")) { try { String val = command.substring(19); findCharactersPerAccount(activeChar, val); } catch (Exception e) { // Case of empty or malformed player name activeChar.sendMessage(391); listCharacters(activeChar, 0); } } else if (command.equals("admin_edit_character")) editCharacter(activeChar); // Karma control commands else if (command.equals("admin_nokarma")) setTargetKarma(activeChar, 0); else if (command.startsWith("admin_setkarma")) { try { String val = command.substring(15); int karma = Integer.parseInt(val); setTargetKarma(activeChar, karma); } catch (Exception e) { if (Config.DEVELOPER) _log.warning("Set karma error: " + e); activeChar.sendMessage(419); } } else if (command.startsWith("admin_setfame")) { try { String val = command.substring(14); int fame = Integer.parseInt(val); L2Object target = activeChar.getTarget(); if (target instanceof L2PcInstance) { L2PcInstance player = (L2PcInstance) target; player.setFame(fame); player.sendPacket(new UserInfo(player)); player.sendPacket(new ExBrExtraUserInfo(player)); L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[261]); cm.addNumber(fame); cm.sendMessage(player); } else { activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET)); } } catch (Exception e) { if (Config.DEVELOPER) _log.warning("Set Fame error: " + e); activeChar.sendMessage(316); } } else if (command.startsWith("admin_save_modifications")) { try { String val = command.substring(24); adminModifyCharacter(activeChar, val); } catch (StringIndexOutOfBoundsException e) { // Case of empty character name activeChar.sendMessage(113); listCharacters(activeChar, 0); } } else if (command.startsWith("admin_rec")) { try { String val = command.substring(10); int recVal = Integer.parseInt(val); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.setRecomHave(recVal); player.sendMessage(528); player.broadcastUserInfo(); } catch (Exception e) { activeChar.sendMessage(414); } } else if (command.startsWith("admin_setclass")) { try { String val = command.substring(15); int classidval = Integer.parseInt(val); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) player = (L2PcInstance) target; else return false; boolean valid = false; for (ClassId classid : ClassId.values()) if (classidval == classid.getId()) valid = true; if (valid && (player.getClassId().getId() != classidval)) { player.setClassId(classidval); if (!player.isSubClassActive()) player.setBaseClass(classidval); String newclass = player.getTemplate().className; player.store(); L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[14]); cm.addString(newclass); cm.sendMessage(player); player.broadcastUserInfo(); cm = new L2CoreMessage(MessageTable.Messages[670]); cm.addString(player.getName()); cm.addString(newclass); cm.sendMessage(activeChar); } activeChar.sendMessage(418); } catch (StringIndexOutOfBoundsException e) { AdminHelpPage.showHelpPage(activeChar, "charclasses.htm"); } } else if (command.startsWith("admin_settitle")) { try { String val = command.substring(15); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.setTitle(val); player.sendMessage(644); player.broadcastTitleInfo(); } catch (StringIndexOutOfBoundsException e) { // Case of empty character title activeChar.sendMessage(584); } } else if (command.startsWith("admin_changename")) { try { String val = command.substring(17); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } L2World.getInstance().removeFromAllPlayers(player); player.setName(val); player.store(); L2World.getInstance().addToAllPlayers(player); player.sendMessage(623); player.broadcastUserInfo(); if (player.isInParty()) { // Delete party window for other party members player.getParty().broadcastToPartyMembers(player, new PartySmallWindowDeleteAll()); for (L2PcInstance member : player.getParty().getPartyMembers()) { // And re-add if (member != player) member.sendPacket(new PartySmallWindowAll(member, player.getParty())); } } if (player.getClan() != null) { player.getClan().broadcastClanStatus(); } RegionBBSManager.getInstance().changeCommunityBoard(); } catch (StringIndexOutOfBoundsException e) { // Case of empty character name activeChar.sendMessage(420); } } else if (command.startsWith("admin_setsex")) { L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.getAppearance().setSex(player.getAppearance().getSex() ? false : true); player.sendMessage(621); player.broadcastUserInfo(); player.decayMe(); player.spawnMe(player.getX(), player.getY(), player.getZ()); } else if (command.startsWith("admin_setcolor")) { try { String val = command.substring(15); L2Object target = activeChar.getTarget(); L2PcInstance player = null; if (target instanceof L2PcInstance) { player = (L2PcInstance) target; } else { return false; } player.getAppearance().setNameColor(Integer.decode("0x" + val)); player.sendMessage(622); player.broadcastUserInfo(); } catch (Exception e) { // Case of empty color or invalid hex string activeChar.sendMessage(583); } } else if (command.startsWith("admin_fullfood")) { L2Object target = activeChar.getTarget(); if (target instanceof L2PetInstance) { L2PetInstance targetPet = (L2PetInstance) target; targetPet.setCurrentFed(targetPet.getMaxFed()); targetPet .getOwner() .sendPacket(new SetSummonRemainTime(targetPet.getMaxFed(), targetPet.getCurrentFed())); } else activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET)); } else if (command.startsWith("admin_unpenalty")) { try { StringTokenizer st = new StringTokenizer(command, " "); if (st.countTokens() != 3) { activeChar.sendMessage(364); return false; } st.nextToken(); boolean changeCreateExpiryTime = st.nextToken().equalsIgnoreCase("create"); String playerName = st.nextToken(); L2PcInstance player = null; player = L2World.getInstance().getPlayer(playerName); if (player == null) { Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps = con.prepareStatement( "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1"); ps.setString(1, playerName); ps.execute(); } else { // removing penalty if (changeCreateExpiryTime) player.setClanCreateExpiryTime(0); else player.setClanJoinExpiryTime(0); } L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[470]); cm.addString(playerName); cm.sendMessage(activeChar); } catch (Exception e) { e.printStackTrace(); } } else if (command.startsWith("admin_find_dualbox")) { int multibox = 2; try { String val = command.substring(19); multibox = Integer.parseInt(val); if (multibox < 1) { activeChar.sendMessage(97); return false; } } catch (Exception e) { } findDualbox(activeChar, multibox); } return true; }
public void activate(L2PcInstance player, ItemInstance item) { // if the player is mounted, attempt to unmount first and pick it if successful. if (player.isMounted() && !player.dismount()) { player.sendPacket( SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_PICKUP_S1) .addItemName(item.getItemId())); item.setDestroyProtected(true); player.dropItem("InvDrop", item, null, true); return; } _isActivated = true; // Hold player data. _player = player; _playerId = _player.getObjectId(); _playerKarma = _player.getKarma(); _playerPkKills = _player.getPkKills(); _item = item; // Generate a random number for next stage. _numberBeforeNextStage = Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5)); // Renew hungry time. _hungryTime = _durationLost * 60; // Activate the daily timer. _dailyTimerTask = ThreadPoolManager.getInstance() .scheduleGeneralAtFixedRate(new DailyTimerTask(), 60000L, 60000L); // Cancel the "1h dropped CW" timer. cancelDropTimerTask(); insertData(); // Change player stats _player.setCursedWeaponEquippedId(_itemId); _player.setKarma(9999999); _player.setPkKills(0); if (_player.isInParty()) _player.getParty().removePartyMember(_player, MessageType.Expelled); // Disable active toggles for (L2Effect effect : _player.getAllEffects()) { if (effect.getSkill().isToggle()) effect.exit(); } // Add CW skills giveDemonicSkills(); // Equip the weapon _player.useEquippableItem(_item, true); // Fully heal player _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp()); _player.setCurrentCp(_player.getMaxCp()); // Refresh player stats _player.broadcastUserInfo(); // _player.broadcastPacket(new SocialAction(_player, 17)); Broadcast.toAllOnlinePlayers( SystemMessage.getSystemMessage( SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION) .addZoneName(_player.getX(), _player.getY(), _player.getZ()) .addItemName(_item.getItemId())); }