This commit is contained in:
@@ -0,0 +1,513 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.enums.ItemLocation;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.L2Armor;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.L2Weapon;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public abstract class AbstractRefinePacket extends L2GameClientPacket
|
||||
{
|
||||
public static final int GRADE_NONE = 0;
|
||||
public static final int GRADE_MID = 1;
|
||||
public static final int GRADE_HIGH = 2;
|
||||
public static final int GRADE_TOP = 3;
|
||||
public static final int GRADE_ACC = 4; // Accessory LS
|
||||
|
||||
protected static final int GEMSTONE_D = 2130;
|
||||
protected static final int GEMSTONE_C = 2131;
|
||||
protected static final int GEMSTONE_B = 2132;
|
||||
|
||||
private static final Map<Integer, LifeStone> _lifeStones = new HashMap<>();
|
||||
|
||||
protected static final class LifeStone
|
||||
{
|
||||
// lifestone level to player level table
|
||||
private static final int[] LEVELS =
|
||||
{
|
||||
46,
|
||||
49,
|
||||
52,
|
||||
55,
|
||||
58,
|
||||
61,
|
||||
64,
|
||||
67,
|
||||
70,
|
||||
76,
|
||||
80,
|
||||
82,
|
||||
84,
|
||||
85
|
||||
};
|
||||
private final int _grade;
|
||||
private final int _level;
|
||||
|
||||
public LifeStone(int grade, int level)
|
||||
{
|
||||
_grade = grade;
|
||||
_level = level;
|
||||
}
|
||||
|
||||
public final int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public final int getGrade()
|
||||
{
|
||||
return _grade;
|
||||
}
|
||||
|
||||
public final int getPlayerLevel()
|
||||
{
|
||||
return LEVELS[_level];
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
// itemId, (LS grade, LS level)
|
||||
_lifeStones.put(8723, new LifeStone(GRADE_NONE, 0));
|
||||
_lifeStones.put(8724, new LifeStone(GRADE_NONE, 1));
|
||||
_lifeStones.put(8725, new LifeStone(GRADE_NONE, 2));
|
||||
_lifeStones.put(8726, new LifeStone(GRADE_NONE, 3));
|
||||
_lifeStones.put(8727, new LifeStone(GRADE_NONE, 4));
|
||||
_lifeStones.put(8728, new LifeStone(GRADE_NONE, 5));
|
||||
_lifeStones.put(8729, new LifeStone(GRADE_NONE, 6));
|
||||
_lifeStones.put(8730, new LifeStone(GRADE_NONE, 7));
|
||||
_lifeStones.put(8731, new LifeStone(GRADE_NONE, 8));
|
||||
_lifeStones.put(8732, new LifeStone(GRADE_NONE, 9));
|
||||
|
||||
_lifeStones.put(8733, new LifeStone(GRADE_MID, 0));
|
||||
_lifeStones.put(8734, new LifeStone(GRADE_MID, 1));
|
||||
_lifeStones.put(8735, new LifeStone(GRADE_MID, 2));
|
||||
_lifeStones.put(8736, new LifeStone(GRADE_MID, 3));
|
||||
_lifeStones.put(8737, new LifeStone(GRADE_MID, 4));
|
||||
_lifeStones.put(8738, new LifeStone(GRADE_MID, 5));
|
||||
_lifeStones.put(8739, new LifeStone(GRADE_MID, 6));
|
||||
_lifeStones.put(8740, new LifeStone(GRADE_MID, 7));
|
||||
_lifeStones.put(8741, new LifeStone(GRADE_MID, 8));
|
||||
_lifeStones.put(8742, new LifeStone(GRADE_MID, 9));
|
||||
|
||||
_lifeStones.put(8743, new LifeStone(GRADE_HIGH, 0));
|
||||
_lifeStones.put(8744, new LifeStone(GRADE_HIGH, 1));
|
||||
_lifeStones.put(8745, new LifeStone(GRADE_HIGH, 2));
|
||||
_lifeStones.put(8746, new LifeStone(GRADE_HIGH, 3));
|
||||
_lifeStones.put(8747, new LifeStone(GRADE_HIGH, 4));
|
||||
_lifeStones.put(8748, new LifeStone(GRADE_HIGH, 5));
|
||||
_lifeStones.put(8749, new LifeStone(GRADE_HIGH, 6));
|
||||
_lifeStones.put(8750, new LifeStone(GRADE_HIGH, 7));
|
||||
_lifeStones.put(8751, new LifeStone(GRADE_HIGH, 8));
|
||||
_lifeStones.put(8752, new LifeStone(GRADE_HIGH, 9));
|
||||
|
||||
_lifeStones.put(8753, new LifeStone(GRADE_TOP, 0));
|
||||
_lifeStones.put(8754, new LifeStone(GRADE_TOP, 1));
|
||||
_lifeStones.put(8755, new LifeStone(GRADE_TOP, 2));
|
||||
_lifeStones.put(8756, new LifeStone(GRADE_TOP, 3));
|
||||
_lifeStones.put(8757, new LifeStone(GRADE_TOP, 4));
|
||||
_lifeStones.put(8758, new LifeStone(GRADE_TOP, 5));
|
||||
_lifeStones.put(8759, new LifeStone(GRADE_TOP, 6));
|
||||
_lifeStones.put(8760, new LifeStone(GRADE_TOP, 7));
|
||||
_lifeStones.put(8761, new LifeStone(GRADE_TOP, 8));
|
||||
_lifeStones.put(8762, new LifeStone(GRADE_TOP, 9));
|
||||
|
||||
_lifeStones.put(9573, new LifeStone(GRADE_NONE, 10));
|
||||
_lifeStones.put(9574, new LifeStone(GRADE_MID, 10));
|
||||
_lifeStones.put(9575, new LifeStone(GRADE_HIGH, 10));
|
||||
_lifeStones.put(9576, new LifeStone(GRADE_TOP, 10));
|
||||
|
||||
_lifeStones.put(10483, new LifeStone(GRADE_NONE, 11));
|
||||
_lifeStones.put(10484, new LifeStone(GRADE_MID, 11));
|
||||
_lifeStones.put(10485, new LifeStone(GRADE_HIGH, 11));
|
||||
_lifeStones.put(10486, new LifeStone(GRADE_TOP, 11));
|
||||
|
||||
_lifeStones.put(12754, new LifeStone(GRADE_ACC, 0));
|
||||
_lifeStones.put(12755, new LifeStone(GRADE_ACC, 1));
|
||||
_lifeStones.put(12756, new LifeStone(GRADE_ACC, 2));
|
||||
_lifeStones.put(12757, new LifeStone(GRADE_ACC, 3));
|
||||
_lifeStones.put(12758, new LifeStone(GRADE_ACC, 4));
|
||||
_lifeStones.put(12759, new LifeStone(GRADE_ACC, 5));
|
||||
_lifeStones.put(12760, new LifeStone(GRADE_ACC, 6));
|
||||
_lifeStones.put(12761, new LifeStone(GRADE_ACC, 7));
|
||||
_lifeStones.put(12762, new LifeStone(GRADE_ACC, 8));
|
||||
_lifeStones.put(12763, new LifeStone(GRADE_ACC, 9));
|
||||
|
||||
_lifeStones.put(12821, new LifeStone(GRADE_ACC, 10));
|
||||
_lifeStones.put(12822, new LifeStone(GRADE_ACC, 11));
|
||||
|
||||
_lifeStones.put(12840, new LifeStone(GRADE_ACC, 0));
|
||||
_lifeStones.put(12841, new LifeStone(GRADE_ACC, 1));
|
||||
_lifeStones.put(12842, new LifeStone(GRADE_ACC, 2));
|
||||
_lifeStones.put(12843, new LifeStone(GRADE_ACC, 3));
|
||||
_lifeStones.put(12844, new LifeStone(GRADE_ACC, 4));
|
||||
_lifeStones.put(12845, new LifeStone(GRADE_ACC, 5));
|
||||
_lifeStones.put(12846, new LifeStone(GRADE_ACC, 6));
|
||||
_lifeStones.put(12847, new LifeStone(GRADE_ACC, 7));
|
||||
_lifeStones.put(12848, new LifeStone(GRADE_ACC, 8));
|
||||
_lifeStones.put(12849, new LifeStone(GRADE_ACC, 9));
|
||||
_lifeStones.put(12850, new LifeStone(GRADE_ACC, 10));
|
||||
_lifeStones.put(12851, new LifeStone(GRADE_ACC, 11));
|
||||
|
||||
_lifeStones.put(14008, new LifeStone(GRADE_ACC, 12));
|
||||
|
||||
_lifeStones.put(14166, new LifeStone(GRADE_NONE, 12));
|
||||
_lifeStones.put(14167, new LifeStone(GRADE_MID, 12));
|
||||
_lifeStones.put(14168, new LifeStone(GRADE_HIGH, 12));
|
||||
_lifeStones.put(14169, new LifeStone(GRADE_TOP, 12));
|
||||
|
||||
_lifeStones.put(16160, new LifeStone(GRADE_NONE, 13));
|
||||
_lifeStones.put(16161, new LifeStone(GRADE_MID, 13));
|
||||
_lifeStones.put(16162, new LifeStone(GRADE_HIGH, 13));
|
||||
_lifeStones.put(16163, new LifeStone(GRADE_TOP, 13));
|
||||
_lifeStones.put(16177, new LifeStone(GRADE_ACC, 13));
|
||||
|
||||
_lifeStones.put(16164, new LifeStone(GRADE_NONE, 13));
|
||||
_lifeStones.put(16165, new LifeStone(GRADE_MID, 13));
|
||||
_lifeStones.put(16166, new LifeStone(GRADE_HIGH, 13));
|
||||
_lifeStones.put(16167, new LifeStone(GRADE_TOP, 13));
|
||||
_lifeStones.put(16178, new LifeStone(GRADE_ACC, 13));
|
||||
}
|
||||
|
||||
protected static final LifeStone getLifeStone(int itemId)
|
||||
{
|
||||
return _lifeStones.get(itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks player, source item, lifestone and gemstone validity for augmentation process
|
||||
* @param player
|
||||
* @param item
|
||||
* @param refinerItem
|
||||
* @param gemStones
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance refinerItem, L2ItemInstance gemStones)
|
||||
{
|
||||
if (!isValid(player, item, refinerItem))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// GemStones must belong to owner
|
||||
if (gemStones.getOwnerId() != player.getObjectId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// .. and located in inventory
|
||||
if (gemStones.getItemLocation() != ItemLocation.INVENTORY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final CrystalType grade = item.getItem().getItemGrade();
|
||||
final LifeStone ls = _lifeStones.get(refinerItem.getId());
|
||||
|
||||
// Check for item id
|
||||
if (getGemStoneId(grade) != gemStones.getId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Count must be greater or equal of required number
|
||||
if (getGemStoneCount(grade, ls.getGrade()) > gemStones.getCount())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks player, source item and lifestone validity for augmentation process
|
||||
* @param player
|
||||
* @param item
|
||||
* @param refinerItem
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance refinerItem)
|
||||
{
|
||||
if (!isValid(player, item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Item must belong to owner
|
||||
if (refinerItem.getOwnerId() != player.getObjectId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Lifestone must be located in inventory
|
||||
if (refinerItem.getItemLocation() != ItemLocation.INVENTORY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final LifeStone ls = _lifeStones.get(refinerItem.getId());
|
||||
if (ls == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// weapons can't be augmented with accessory ls
|
||||
if ((item.getItem() instanceof L2Weapon) && (ls.getGrade() == GRADE_ACC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// and accessory can't be augmented with weapon ls
|
||||
if ((item.getItem() instanceof L2Armor) && (ls.getGrade() != GRADE_ACC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// check for level of the lifestone
|
||||
if (player.getLevel() < ls.getPlayerLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check both player and source item conditions for augmentation process
|
||||
* @param player
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player, L2ItemInstance item)
|
||||
{
|
||||
if (!isValid(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Item must belong to owner
|
||||
if (item.getOwnerId() != player.getObjectId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isAugmented())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isHeroItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isShadowItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isCommonItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isEtcItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isTimeLimitedItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.isPvp() && !Config.ALT_ALLOW_AUGMENT_PVP_ITEMS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item.getItem().getCrystalType().isLesser(CrystalType.C))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Source item can be equipped or in inventory
|
||||
switch (item.getItemLocation())
|
||||
{
|
||||
case INVENTORY:
|
||||
case PAPERDOLL:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.getItem() instanceof L2Weapon)
|
||||
{
|
||||
switch (((L2Weapon) item.getItem()).getItemType())
|
||||
{
|
||||
case NONE:
|
||||
case FISHINGROD:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (item.getItem() instanceof L2Armor)
|
||||
{
|
||||
// only accessories can be augmented
|
||||
switch (item.getItem().getBodyPart())
|
||||
{
|
||||
case L2Item.SLOT_LR_FINGER:
|
||||
case L2Item.SLOT_LR_EAR:
|
||||
case L2Item.SLOT_NECK:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // neither weapon nor armor ?
|
||||
}
|
||||
|
||||
// blacklist check
|
||||
if (Arrays.binarySearch(Config.AUGMENTATION_BLACKLIST, item.getId()) >= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if player's conditions valid for augmentation process
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
protected static final boolean isValid(L2PcInstance player)
|
||||
{
|
||||
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP_IS_IN_OPERATION);
|
||||
return false;
|
||||
}
|
||||
if (player.getActiveTradeList() != null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_ENGAGED_IN_TRADE_ACTIVITIES);
|
||||
return false;
|
||||
}
|
||||
if (player.isDead())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_DEAD);
|
||||
return false;
|
||||
}
|
||||
if (player.isParalyzed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_PARALYZED);
|
||||
return false;
|
||||
}
|
||||
if (player.isFishing())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_FISHING);
|
||||
return false;
|
||||
}
|
||||
if (player.isSitting())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_SITTING_DOWN);
|
||||
return false;
|
||||
}
|
||||
if (player.isCursedWeaponEquipped())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (player.isEnchanting() || player.isProcessingTransaction())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemGrade
|
||||
* @return GemStone itemId based on item grade
|
||||
*/
|
||||
protected static final int getGemStoneId(CrystalType itemGrade)
|
||||
{
|
||||
switch (itemGrade)
|
||||
{
|
||||
case C:
|
||||
case B:
|
||||
return GEMSTONE_D;
|
||||
case A:
|
||||
case S:
|
||||
return GEMSTONE_C;
|
||||
case S80:
|
||||
case S84:
|
||||
return GEMSTONE_B;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Different for weapon and accessory augmentation.
|
||||
* @param itemGrade
|
||||
* @param lifeStoneGrade
|
||||
* @return GemStone count based on item grade and life stone grade
|
||||
*/
|
||||
protected static final int getGemStoneCount(CrystalType itemGrade, int lifeStoneGrade)
|
||||
{
|
||||
switch (lifeStoneGrade)
|
||||
{
|
||||
case GRADE_ACC:
|
||||
switch (itemGrade)
|
||||
{
|
||||
case C:
|
||||
return 200;
|
||||
case B:
|
||||
return 300;
|
||||
case A:
|
||||
return 200;
|
||||
case S:
|
||||
return 250;
|
||||
case S80:
|
||||
return 360;
|
||||
case S84:
|
||||
return 480;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
switch (itemGrade)
|
||||
{
|
||||
case C:
|
||||
return 20;
|
||||
case B:
|
||||
return 30;
|
||||
case A:
|
||||
return 20;
|
||||
case S:
|
||||
return 25;
|
||||
case S80:
|
||||
case S84:
|
||||
return 36;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jserver.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jserver.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public final class Action extends L2GameClientPacket
|
||||
{
|
||||
private static final String __C__1F_ACTION = "[C] 1F Action";
|
||||
|
||||
private int _objectId;
|
||||
private int _originX;
|
||||
private int _originY;
|
||||
private int _originZ;
|
||||
private int _actionId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD(); // Target object Identifier
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_actionId = readC(); // Action identifier : 0-Simple click, 1-Shift click
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info(getType() + ": " + (_actionId == 0 ? "Simple-click" : "Shift-click") + " Target object ID: " + _objectId + " orignX: " + _originX + " orignY: " + _originY + " orignZ: " + _originZ);
|
||||
}
|
||||
|
||||
// Get the current L2PcInstance of the player
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
|
||||
if (info != null)
|
||||
{
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
if (!effect.checkCondition(-4))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final L2Object obj;
|
||||
if (activeChar.getTargetId() == _objectId)
|
||||
{
|
||||
obj = activeChar.getTarget();
|
||||
}
|
||||
else if (activeChar.isInAirShip() && (activeChar.getAirShip().getHelmObjectId() == _objectId))
|
||||
{
|
||||
obj = activeChar.getAirShip();
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = L2World.getInstance().findObject(_objectId);
|
||||
}
|
||||
|
||||
// If object requested does not exist, add warn msg into logs
|
||||
if (obj == null)
|
||||
{
|
||||
// pressing e.g. pickup many times quickly would get you here
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't interact with objects in the other instances, except from multiverse
|
||||
if ((obj.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly interact with invisible characters
|
||||
if (!obj.isVisibleFor(activeChar))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the target is valid, if the player haven't a shop or isn't the requester of a transaction (ex : FriendInvite, JoinAlly, JoinParty...)
|
||||
if (activeChar.getActiveRequester() != null)
|
||||
{
|
||||
// Actions prohibited when in trade
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_actionId)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
obj.onAction(activeChar);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (!activeChar.isGM() && !(obj.isNpc() && Config.ALT_GAME_VIEWNPC))
|
||||
{
|
||||
obj.onAction(activeChar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.onActionShift(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Invalid action detected (probably client cheating), log this
|
||||
_log.warning(getType() + ": Character: " + activeChar.getName() + " requested invalid action: " + _actionId);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return __C__1F_ACTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.TradeItem;
|
||||
import com.l2jserver.gameserver.model.TradeList;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.TradeOtherAdd;
|
||||
import com.l2jserver.gameserver.network.serverpackets.TradeOwnAdd;
|
||||
import com.l2jserver.gameserver.network.serverpackets.TradeUpdate;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.2.2.5 $ $Date: 2005/03/27 15:29:29 $
|
||||
*/
|
||||
public final class AddTradeItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__1B_ADDTRADEITEM = "[C] 1B AddTradeItem";
|
||||
|
||||
private int _tradeId;
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_tradeId = readD();
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TradeList trade = player.getActiveTradeList();
|
||||
if (trade == null)
|
||||
{
|
||||
_log.warning("Character: " + player.getName() + " requested item:" + _objectId + " add without active tradelist:" + _tradeId);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance partner = trade.getPartner();
|
||||
if ((partner == null) || (L2World.getInstance().getPlayer(partner.getObjectId()) == null) || (partner.getActiveTradeList() == null))
|
||||
{
|
||||
// Trade partner not found, cancel trade
|
||||
if (partner != null)
|
||||
{
|
||||
_log.warning("Character:" + player.getName() + " requested invalid trade object: " + _objectId);
|
||||
}
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
player.cancelActiveTrade();
|
||||
return;
|
||||
}
|
||||
|
||||
if (trade.isConfirmed() || partner.getActiveTradeList().isConfirmed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_MAY_NO_LONGER_ADJUST_ITEMS_IN_THE_TRADE_BECAUSE_THE_TRADE_HAS_BEEN_CONFIRMED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.getAccessLevel().allowTransaction())
|
||||
{
|
||||
player.sendMessage("Transactions are disabled for your Access Level.");
|
||||
player.cancelActiveTrade();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.validateItemManipulation(_objectId, "trade"))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.NOTHING_HAPPENED);
|
||||
return;
|
||||
}
|
||||
|
||||
final TradeItem item = trade.addItem(_objectId, _count);
|
||||
if (item != null)
|
||||
{
|
||||
player.sendPacket(new TradeOwnAdd(item));
|
||||
player.sendPacket(new TradeUpdate(player, item));
|
||||
partner.sendPacket(new TradeOtherAdd(item));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__1B_ADDTRADEITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ClanTable;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class AllyDismiss extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__8F_ALLYDISMISS = "[C] 8F AllyDismiss";
|
||||
|
||||
private String _clanName;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_clanName = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (_clanName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getClan() == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER_AND_CANNOT_PERFORM_THIS_ACTION);
|
||||
return;
|
||||
}
|
||||
L2Clan leaderClan = player.getClan();
|
||||
if (leaderClan.getAllyId() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_ALLIED_WITH_ANY_CLANS);
|
||||
return;
|
||||
}
|
||||
if (!player.isClanLeader() || (leaderClan.getId() != leaderClan.getAllyId()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THIS_FEATURE_IS_ONLY_AVAILABLE_TO_ALLIANCE_LEADERS);
|
||||
return;
|
||||
}
|
||||
L2Clan clan = ClanTable.getInstance().getClanByName(_clanName);
|
||||
if (clan == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_CLAN_DOES_NOT_EXIST);
|
||||
return;
|
||||
}
|
||||
if (clan.getId() == leaderClan.getId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ALLIANCE_LEADERS_CANNOT_WITHDRAW);
|
||||
return;
|
||||
}
|
||||
if (clan.getAllyId() != leaderClan.getAllyId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.DIFFERENT_ALLIANCE);
|
||||
return;
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
leaderClan.setAllyPenaltyExpiryTime(currentTime + (Config.ALT_ACCEPT_CLAN_DAYS_WHEN_DISMISSED * 86400000L), L2Clan.PENALTY_TYPE_DISMISS_CLAN); // 24*60*60*1000 = 86400000
|
||||
leaderClan.updateClanInDB();
|
||||
|
||||
clan.setAllyId(0);
|
||||
clan.setAllyName(null);
|
||||
clan.changeAllyCrest(0, true);
|
||||
clan.setAllyPenaltyExpiryTime(currentTime + (Config.ALT_ALLY_JOIN_DAYS_WHEN_DISMISSED * 86400000L), L2Clan.PENALTY_TYPE_CLAN_DISMISSED); // 24*60*60*1000 = 86400000
|
||||
clan.updateClanInDB();
|
||||
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_SUCCEEDED_IN_EXPELLING_THE_CLAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__8F_ALLYDISMISS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class AllyLeave extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__8E_ALLYLEAVE = "[C] 8E AllyLeave";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getClan() == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER_AND_CANNOT_PERFORM_THIS_ACTION);
|
||||
return;
|
||||
}
|
||||
if (!player.isClanLeader())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ONLY_THE_CLAN_LEADER_MAY_APPLY_FOR_WITHDRAWAL_FROM_THE_ALLIANCE);
|
||||
return;
|
||||
}
|
||||
L2Clan clan = player.getClan();
|
||||
if (clan.getAllyId() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_ALLIED_WITH_ANY_CLANS);
|
||||
return;
|
||||
}
|
||||
if (clan.getId() == clan.getAllyId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ALLIANCE_LEADERS_CANNOT_WITHDRAW);
|
||||
return;
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
clan.setAllyId(0);
|
||||
clan.setAllyName(null);
|
||||
clan.changeAllyCrest(0, true);
|
||||
clan.setAllyPenaltyExpiryTime(currentTime + (Config.ALT_ALLY_JOIN_DAYS_WHEN_LEAVED * 86400000L), L2Clan.PENALTY_TYPE_CLAN_LEAVED); // 24*60*60*1000 = 86400000
|
||||
clan.updateClanInDB();
|
||||
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_THE_ALLIANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__8E_ALLYLEAVE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExRotation;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class AnswerCoupleAction extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_7A_ANSWERCOUPLEACTION = "[C] D0:7A AnswerCoupleAction";
|
||||
|
||||
private int _charObjId;
|
||||
private int _actionId;
|
||||
private int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_actionId = readD();
|
||||
_answer = readD();
|
||||
_charObjId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getActiveChar();
|
||||
L2PcInstance target = L2World.getInstance().getPlayer(_charObjId);
|
||||
if ((activeChar == null) || (target == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((target.getMultiSocialTarget() != activeChar.getObjectId()) || (target.getMultiSociaAction() != _actionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_answer == 0) // cancel
|
||||
{
|
||||
target.sendPacket(SystemMessageId.THE_COUPLE_ACTION_WAS_DENIED);
|
||||
}
|
||||
else if (_answer == 1) // approve
|
||||
{
|
||||
final int distance = (int) activeChar.calculateDistance(target, false, false);
|
||||
if ((distance > 125) || (distance < 15) || (activeChar.getObjectId() == target.getObjectId()))
|
||||
{
|
||||
sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
target.sendPacket(SystemMessageId.THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS);
|
||||
return;
|
||||
}
|
||||
int heading = Util.calculateHeadingFrom(activeChar, target);
|
||||
activeChar.broadcastPacket(new ExRotation(activeChar.getObjectId(), heading));
|
||||
activeChar.setHeading(heading);
|
||||
heading = Util.calculateHeadingFrom(target, activeChar);
|
||||
target.setHeading(heading);
|
||||
target.broadcastPacket(new ExRotation(target.getObjectId(), heading));
|
||||
activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), _actionId));
|
||||
target.broadcastPacket(new SocialAction(_charObjId, _actionId));
|
||||
}
|
||||
else if (_answer == -1) // refused
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_COUPLE_ACTIONS_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
|
||||
sm.addPcName(activeChar);
|
||||
target.sendPacket(sm);
|
||||
}
|
||||
target.setMultiSocialAction(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_7A_ANSWERCOUPLEACTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jserver.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jserver.gameserver.model.PartyMatchWaitingList;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPartyRoomMember;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PartyMatchDetail;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format: (ch) d
|
||||
* @author -Wooden-, Tryskell
|
||||
*/
|
||||
public final class AnswerJoinPartyRoom extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_30_ANSWERJOINPARTYROOM = "[C] D0:30 AnswerJoinPartyRoom";
|
||||
private int _answer; // 1 or 0
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_answer = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance partner = player.getActiveRequester();
|
||||
if (partner == null)
|
||||
{
|
||||
// Partner hasn't been found, cancel the invitation
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
else if (L2World.getInstance().getPlayer(partner.getObjectId()) == null)
|
||||
{
|
||||
// Partner hasn't been found, cancel the invitation
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// If answer is positive, join the requester's PartyRoom.
|
||||
if ((_answer == 1) && !partner.isRequestExpired())
|
||||
{
|
||||
PartyMatchRoom room = PartyMatchRoomList.getInstance().getRoom(partner.getPartyRoom());
|
||||
if (room == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((player.getLevel() >= room.getMinLvl()) && (player.getLevel() <= room.getMaxLvl()))
|
||||
{
|
||||
// Remove from waiting list
|
||||
PartyMatchWaitingList.getInstance().removePlayer(player);
|
||||
|
||||
player.setPartyRoom(partner.getPartyRoom());
|
||||
|
||||
player.sendPacket(new PartyMatchDetail(player, room));
|
||||
player.sendPacket(new ExPartyRoomMember(player, room, 0));
|
||||
|
||||
for (L2PcInstance member : room.getPartyMembers())
|
||||
{
|
||||
if (member == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
member.sendPacket(new ExManagePartyRoomMember(player, room, 0));
|
||||
member.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ENTERED_THE_PARTY_ROOM).addPcName(player));
|
||||
}
|
||||
room.addMember(player);
|
||||
|
||||
// Info Broadcast
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_REQUIREMENTS_TO_ENTER_THAT_PARTY_ROOM);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
partner.sendPacket(SystemMessageId.THE_RECIPIENT_OF_YOUR_INVITATION_DID_NOT_ACCEPT_THE_PARTY_MATCHING_INVITATION);
|
||||
}
|
||||
|
||||
// reset transaction timers
|
||||
player.setActiveRequester(null);
|
||||
partner.onTransactionResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_30_ANSWERJOINPARTYROOM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Party;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public class AnswerPartyLootModification extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_79_ANSWERPARTYLOOTMODIFICATION = "[C] D0:79 AnswerPartyLootModification";
|
||||
|
||||
public int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_answer = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
L2Party party = activeChar.getParty();
|
||||
if (party != null)
|
||||
{
|
||||
party.answerLootChangeRequest(activeChar, _answer == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_79_ANSWERPARTYLOOTMODIFICATION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.TradeDone;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.4.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class AnswerTradeRequest extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__55_ANSWERTRADEREQUEST = "[C] 55 AnswerTradeRequest";
|
||||
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.getAccessLevel().allowTransaction())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance partner = player.getActiveRequester();
|
||||
if (partner == null)
|
||||
{
|
||||
// Trade partner not found, cancel trade
|
||||
player.sendPacket(new TradeDone(0));
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE));
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
else if (L2World.getInstance().getPlayer(partner.getObjectId()) == null)
|
||||
{
|
||||
// Trade partner not found, cancel trade
|
||||
player.sendPacket(new TradeDone(0));
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE));
|
||||
player.setActiveRequester(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_response == 1) && !partner.isRequestExpired())
|
||||
{
|
||||
player.startTrade(partner);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_DENIED_YOUR_REQUEST_TO_TRADE);
|
||||
msg.addString(player.getName());
|
||||
partner.sendPacket(msg);
|
||||
}
|
||||
|
||||
// Clears requesting status
|
||||
player.setActiveRequester(null);
|
||||
partner.onTransactionResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__55_ANSWERTRADEREQUEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* Appearing Packet Handler
|
||||
* <p>
|
||||
* <p>
|
||||
* 0000: 30
|
||||
* <p>
|
||||
* <p>
|
||||
* @version $Revision: 1.3.4.4 $ $Date: 2005/03/29 23:15:33 $
|
||||
*/
|
||||
public final class Appearing extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__3A_APPEARING = "[C] 3A Appearing";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.isTeleporting())
|
||||
{
|
||||
activeChar.onTeleported();
|
||||
}
|
||||
|
||||
sendPacket(new UserInfo(activeChar));
|
||||
sendPacket(new ExBrExtraUserInfo(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__3A_APPEARING;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jserver.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jserver.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
/**
|
||||
* TODO: This class is a copy of AttackRequest, we should get proper structure for both.
|
||||
*/
|
||||
public final class Attack extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__01_ATTACK = "[C] 01 Attack";
|
||||
|
||||
// cddddc
|
||||
private int _objectId;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originX;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originY;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originZ;
|
||||
@SuppressWarnings("unused")
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_attackId = readC(); // 0 for simple click 1 for shift-click
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid Attacks in Boat.
|
||||
if (activeChar.isPlayable() && activeChar.isInBoat())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_ALLOWED_WHILE_RIDING_A_FERRY_OR_BOAT);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
|
||||
if (info != null)
|
||||
{
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
if (!effect.checkCondition(-1))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// avoid using expensive operations if not needed
|
||||
final L2Object target;
|
||||
if (activeChar.getTargetId() == _objectId)
|
||||
{
|
||||
target = activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
target = L2World.getInstance().findObject(_objectId);
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't attack objects in the other instances
|
||||
// except from multiverse
|
||||
else if ((target.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly attack invisible characters
|
||||
else if (!target.isVisibleFor(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
target.onAction(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((target.getObjectId() != activeChar.getObjectId()) && (activeChar.getPrivateStoreType() == PrivateStoreType.NONE) && (activeChar.getActiveRequester() == null))
|
||||
{
|
||||
target.onForcedAttack(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__01_ATTACK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jserver.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jserver.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public final class AttackRequest extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__32_ATTACKREQUEST = "[C] 32 AttackRequest";
|
||||
|
||||
// cddddc
|
||||
private int _objectId;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originX;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originY;
|
||||
@SuppressWarnings("unused")
|
||||
private int _originZ;
|
||||
@SuppressWarnings("unused")
|
||||
private int _attackId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
_attackId = readC(); // 0 for simple click 1 for shift-click
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
|
||||
if (info != null)
|
||||
{
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
if (!effect.checkCondition(-1))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// avoid using expensive operations if not needed
|
||||
final L2Object target;
|
||||
if (activeChar.getTargetId() == _objectId)
|
||||
{
|
||||
target = activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
target = L2World.getInstance().findObject(_objectId);
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!target.isTargetable() && !activeChar.canOverrideCond(PcCondOverride.TARGET_ALL))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Players can't attack objects in the other instances
|
||||
// except from multiverse
|
||||
else if ((target.getInstanceId() != activeChar.getInstanceId()) && (activeChar.getInstanceId() != -1))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only GMs can directly attack invisible characters
|
||||
else if (!target.isVisibleFor(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
target.onAction(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((target.getObjectId() != activeChar.getObjectId()) && (activeChar.getPrivateStoreType() == PrivateStoreType.NONE) && (activeChar.getActiveRequester() == null))
|
||||
{
|
||||
target.onForcedAttack(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__32_ATTACKREQUEST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.LoginServerThread;
|
||||
import com.l2jserver.gameserver.LoginServerThread.SessionKey;
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.9.2.3.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class AuthLogin extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__2B_AUTHLOGIN = "[C] 2B AuthLogin";
|
||||
|
||||
// loginName + keys must match what the loginserver used.
|
||||
private String _loginName;
|
||||
/*
|
||||
* private final long _key1; private final long _key2; private final long _key3; private final long _key4;
|
||||
*/
|
||||
private int _playKey1;
|
||||
private int _playKey2;
|
||||
private int _loginKey1;
|
||||
private int _loginKey2;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_loginName = readS().toLowerCase();
|
||||
_playKey2 = readD();
|
||||
_playKey1 = readD();
|
||||
_loginKey1 = readD();
|
||||
_loginKey2 = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (_loginName.isEmpty() || !client.isProtocolOk())
|
||||
{
|
||||
client.close((L2GameServerPacket) null);
|
||||
return;
|
||||
}
|
||||
SessionKey key = new SessionKey(_loginKey1, _loginKey2, _playKey1, _playKey2);
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("user:" + _loginName);
|
||||
_log.info("key:" + key);
|
||||
}
|
||||
|
||||
// avoid potential exploits
|
||||
if (client.getAccountName() == null)
|
||||
{
|
||||
// Preventing duplicate login in case client login server socket was disconnected or this packet was not sent yet
|
||||
if (LoginServerThread.getInstance().addGameServerLogin(_loginName, client))
|
||||
{
|
||||
client.setAccountName(_loginName);
|
||||
LoginServerThread.getInstance().addWaitingClientAndSendRequest(_loginName, client, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.close((L2GameServerPacket) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__2B_AUTHLOGIN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBrLoadEventTopRankers;
|
||||
|
||||
/**
|
||||
* Halloween rank list client packet. Format: (ch)ddd
|
||||
*/
|
||||
public class BrEventRankerList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_7B_BREVENTRANKERLIST = "[C] D0:7B BrEventRankerList";
|
||||
|
||||
private int _eventId;
|
||||
private int _day;
|
||||
@SuppressWarnings("unused")
|
||||
private int _ranking;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_eventId = readD();
|
||||
_day = readD(); // 0 - current, 1 - previous
|
||||
_ranking = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// TODO count, bestScore, myScore
|
||||
int count = 0;
|
||||
int bestScore = 0;
|
||||
int myScore = 0;
|
||||
getClient().sendPacket(new ExBrLoadEventTopRankers(_eventId, _day, count, bestScore, myScore));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_7B_BREVENTRANKERLIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.handler.IUserCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.UserCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.2.1.2.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class BypassUserCmd extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__B3_BYPASSUSERCMD = "[C] B3 BypassUserCmd";
|
||||
|
||||
private int _command;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_command = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IUserCommandHandler handler = UserCommandHandler.getInstance().getHandler(_command);
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
if (player.isGM())
|
||||
{
|
||||
player.sendMessage("User commandID " + _command + " not implemented yet.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useUserCommand(_command, getClient().getActiveChar());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__B3_BYPASSUSERCMD;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.ai.CtrlEvent;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.2.1.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class CannotMoveAnymore extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__47_STOPMOVE = "[C] 47 CannotMoveAnymore";
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _heading;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_heading = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("client: x:" + _x + " y:" + _y + " z:" + _z + " server x:" + player.getX() + " y:" + player.getY() + " z:" + player.getZ());
|
||||
}
|
||||
if (player.getAI() != null)
|
||||
{
|
||||
player.getAI().notifyEvent(CtrlEvent.EVT_ARRIVED_BLOCKED, new Location(_x, _y, _z, _heading));
|
||||
}
|
||||
/*
|
||||
* if (player.getParty() != null) { player.getParty().broadcastToPartyMembers(player, new PartyMemberPosition(player)); }
|
||||
*/
|
||||
|
||||
// player.stopMove();
|
||||
//
|
||||
// if (Config.DEBUG)
|
||||
// _log.fine("client: x:"+_x+" y:"+_y+" z:"+_z+
|
||||
// " server x:"+player.getX()+" y:"+player.getZ()+" z:"+player.getZ());
|
||||
// StopMove smwl = new StopMove(player);
|
||||
// getClient().getActiveChar().sendPacket(smwl);
|
||||
// getClient().getActiveChar().broadcastPacket(smwl);
|
||||
//
|
||||
// StopRotation sr = new StopRotation(getClient().getActiveChar(),
|
||||
// _heading);
|
||||
// getClient().getActiveChar().sendPacket(sr);
|
||||
// getClient().getActiveChar().broadcastPacket(sr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__47_STOPMOVE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StopMoveInVehicle;
|
||||
|
||||
/**
|
||||
* @author Maktakien
|
||||
*/
|
||||
public final class CannotMoveAnymoreInVehicle extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__76_CANNOTMOVEANYMOREINVEHICLE = "[C] 76 CannotMoveAnymoreInVehicle";
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _heading;
|
||||
private int _boatId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_boatId = readD();
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_heading = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.isInBoat())
|
||||
{
|
||||
if (player.getBoat().getObjectId() == _boatId)
|
||||
{
|
||||
player.setInVehiclePosition(new Location(_x, _y, _z));
|
||||
player.setHeading(_heading);
|
||||
StopMoveInVehicle msg = new StopMoveInVehicle(player, _boatId);
|
||||
player.broadcastPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__76_CANNOTMOVEANYMOREINVEHICLE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.datatables.CharTemplateTable;
|
||||
import com.l2jserver.gameserver.datatables.InitialEquipmentData;
|
||||
import com.l2jserver.gameserver.datatables.InitialShortcutData;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.datatables.SkillTreesData;
|
||||
import com.l2jserver.gameserver.model.L2SkillLearn;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.appearance.PcAppearance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.stat.PcStat;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2PcTemplate;
|
||||
import com.l2jserver.gameserver.model.base.ClassId;
|
||||
import com.l2jserver.gameserver.model.events.Containers;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerCreate;
|
||||
import com.l2jserver.gameserver.model.items.PcItemTemplate;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharCreateFail;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharCreateOk;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class CharacterCreate extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0C_CHARACTERCREATE = "[C] 0C CharacterCreate";
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
// cSdddddddddddd
|
||||
private String _name;
|
||||
private int _race;
|
||||
private byte _sex;
|
||||
private int _classId;
|
||||
private int _int;
|
||||
private int _str;
|
||||
private int _con;
|
||||
private int _men;
|
||||
private int _dex;
|
||||
private int _wit;
|
||||
private byte _hairStyle;
|
||||
private byte _hairColor;
|
||||
private byte _face;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
_race = readD();
|
||||
_sex = (byte) readD();
|
||||
_classId = readD();
|
||||
_int = readD();
|
||||
_str = readD();
|
||||
_con = readD();
|
||||
_men = readD();
|
||||
_dex = readD();
|
||||
_wit = readD();
|
||||
_hairStyle = (byte) readD();
|
||||
_hairColor = (byte) readD();
|
||||
_face = (byte) readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// Last Verified: May 30, 2009 - Gracia Final - Players are able to create characters with names consisting of as little as 1,2,3 letter/number combinations.
|
||||
if ((_name.length() < 1) || (_name.length() > 16))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: Character name " + _name + " is invalid. Message generated: Your title cannot exceed 16 characters in length. Please try again.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.FORBIDDEN_NAMES.length > 1)
|
||||
{
|
||||
for (String st : Config.FORBIDDEN_NAMES)
|
||||
{
|
||||
if (_name.toLowerCase().contains(st.toLowerCase()))
|
||||
{
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Last Verified: May 30, 2009 - Gracia Final
|
||||
if (!Util.isAlphaNumeric(_name) || !isValidName(_name))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: Character name " + _name + " is invalid. Message generated: Incorrect name. Please try again.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_face > 2) || (_face < 0))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character face " + _face + " is invalid. Possible client hack. " + getClient());
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_hairStyle < 0) || ((_sex == 0) && (_hairStyle > 4)) || ((_sex != 0) && (_hairStyle > 6)))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack. " + getClient());
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_hairColor > 3) || (_hairColor < 0))
|
||||
{
|
||||
_log.warning("Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack. " + getClient());
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance newChar = null;
|
||||
L2PcTemplate template = null;
|
||||
|
||||
/*
|
||||
* DrHouse: Since checks for duplicate names are done using SQL, lock must be held until data is written to DB as well.
|
||||
*/
|
||||
synchronized (CharNameTable.getInstance())
|
||||
{
|
||||
if ((CharNameTable.getInstance().getAccountCharacterCount(getClient().getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT) && (Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Max number of characters reached. Creation failed.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS));
|
||||
return;
|
||||
}
|
||||
else if (CharNameTable.getInstance().doesCharNameExist(_name))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: Message generated: You cannot create another character. Please delete the existing character and try again.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS));
|
||||
return;
|
||||
}
|
||||
|
||||
template = CharTemplateTable.getInstance().getTemplate(_classId);
|
||||
if ((template == null) || (ClassId.getClassId(_classId).level() > 0))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character Creation Failure: " + _name + " classId: " + _classId + " Template: " + template + " Message generated: Your character creation has failed.");
|
||||
}
|
||||
|
||||
sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
|
||||
return;
|
||||
}
|
||||
final PcAppearance app = new PcAppearance(_face, _hairColor, _hairStyle, _sex != 0);
|
||||
newChar = L2PcInstance.create(template, getClient().getAccountName(), _name, app);
|
||||
}
|
||||
|
||||
// HP and MP are at maximum and CP is zero by default.
|
||||
newChar.setCurrentHp(newChar.getMaxHp());
|
||||
newChar.setCurrentMp(newChar.getMaxMp());
|
||||
// newChar.setMaxLoad(template.getBaseLoad());
|
||||
|
||||
sendPacket(new CharCreateOk());
|
||||
|
||||
initNewChar(getClient(), newChar);
|
||||
|
||||
LogRecord record = new LogRecord(Level.INFO, "Created new character");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
newChar,
|
||||
getClient()
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
}
|
||||
|
||||
private static boolean isValidName(String text)
|
||||
{
|
||||
return Config.CHARNAME_TEMPLATE_PATTERN.matcher(text).matches();
|
||||
}
|
||||
|
||||
private void initNewChar(L2GameClient client, L2PcInstance newChar)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character init start");
|
||||
}
|
||||
|
||||
L2World.getInstance().storeObject(newChar);
|
||||
|
||||
if (Config.STARTING_ADENA > 0)
|
||||
{
|
||||
newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
|
||||
}
|
||||
|
||||
final L2PcTemplate template = newChar.getTemplate();
|
||||
Location createLoc = template.getCreationPoint();
|
||||
newChar.setXYZInvisible(createLoc.getX(), createLoc.getY(), createLoc.getZ());
|
||||
newChar.setTitle("");
|
||||
|
||||
if (Config.ENABLE_VITALITY)
|
||||
{
|
||||
newChar.setVitalityPoints(Math.min(Config.STARTING_VITALITY_POINTS, PcStat.MAX_VITALITY_POINTS), true);
|
||||
}
|
||||
if (Config.STARTING_LEVEL > 1)
|
||||
{
|
||||
newChar.getStat().addLevel((byte) (Config.STARTING_LEVEL - 1));
|
||||
}
|
||||
if (Config.STARTING_SP > 0)
|
||||
{
|
||||
newChar.getStat().addSp(Config.STARTING_SP);
|
||||
}
|
||||
|
||||
final List<PcItemTemplate> initialItems = InitialEquipmentData.getInstance().getEquipmentList(newChar.getClassId());
|
||||
if (initialItems != null)
|
||||
{
|
||||
for (PcItemTemplate ie : initialItems)
|
||||
{
|
||||
final L2ItemInstance item = newChar.getInventory().addItem("Init", ie.getId(), ie.getCount(), newChar, null);
|
||||
if (item == null)
|
||||
{
|
||||
_log.warning("Could not create item during char creation: itemId " + ie.getId() + ", amount " + ie.getCount() + ".");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.isEquipable() && ie.isEquipped())
|
||||
{
|
||||
newChar.getInventory().equipItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (L2SkillLearn skill : SkillTreesData.getInstance().getRaceSkillTree(newChar.getRace()))
|
||||
{
|
||||
newChar.addSkill(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel()), true);
|
||||
}
|
||||
|
||||
for (L2SkillLearn skill : SkillTreesData.getInstance().getAvailableSkills(newChar, newChar.getClassId(), false, true))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Adding starter skill:" + skill.getSkillId() + " / " + skill.getSkillLevel());
|
||||
}
|
||||
|
||||
newChar.addSkill(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel()), true);
|
||||
}
|
||||
|
||||
// Register all shortcuts for actions, skills and items for this new character.
|
||||
InitialShortcutData.getInstance().registerAllShortcuts(newChar);
|
||||
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerCreate(newChar, newChar.getObjectId(), newChar.getName(), client), Containers.Players());
|
||||
|
||||
newChar.setOnlineStatus(true, false);
|
||||
if (Config.SHOW_GOD_VIDEO_INTRO)
|
||||
{
|
||||
newChar.getVariables().set("intro_god_video", true);
|
||||
}
|
||||
newChar.deleteMe();
|
||||
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);
|
||||
client.setCharSelection(cl.getCharInfo());
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Character init end");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0C_CHARACTERCREATE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jserver.gameserver.model.events.Containers;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerDelete;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharDeleteFail;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharDeleteSuccess;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.8.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class CharacterDelete extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0C_CHARACTERDELETE = "[C] 0D CharacterDelete";
|
||||
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_charSlot = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterDelete"))
|
||||
{
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_DELETION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("deleting slot:" + _charSlot);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
byte answer = getClient().markToDeleteChar(_charSlot);
|
||||
|
||||
switch (answer)
|
||||
{
|
||||
default:
|
||||
case -1: // Error
|
||||
break;
|
||||
case 0: // Success!
|
||||
sendPacket(new CharDeleteSuccess());
|
||||
final CharSelectInfoPackage charInfo = getClient().getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerDelete(charInfo.getObjectId(), charInfo.getName(), getClient()), Containers.Players());
|
||||
break;
|
||||
case 1:
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER));
|
||||
break;
|
||||
case 2:
|
||||
sendPacket(new CharDeleteFail(CharDeleteFail.REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED));
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error:", e);
|
||||
}
|
||||
|
||||
CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0C_CHARACTERDELETE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerRestore;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.4.2.1.2.2 $ $Date: 2005/03/27 15:29:29 $
|
||||
*/
|
||||
public final class CharacterRestore extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__7B_CHARACTERRESTORE = "[C] 7B CharacterRestore";
|
||||
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_charSlot = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!getClient().getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterRestore"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getClient().markRestoredChar(_charSlot);
|
||||
CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
|
||||
sendPacket(cl);
|
||||
getClient().setCharSelection(cl.getCharInfo());
|
||||
final CharSelectInfoPackage charInfo = getClient().getCharSelection(_charSlot);
|
||||
EventDispatcher.getInstance().notifyEvent(new OnPlayerRestore(charInfo.getObjectId(), charInfo.getName(), getClient()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__7B_CHARACTERRESTORE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.datatables.SecondaryAuthData;
|
||||
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jserver.gameserver.model.CharSelectInfoPackage;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.Containers;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSelect;
|
||||
import com.l2jserver.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
|
||||
import com.l2jserver.gameserver.model.punishment.PunishmentType;
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ServerClose;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.1.2.5 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class CharacterSelect extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__12_CHARACTERSELECT = "[C] 12 CharacterSelect";
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
// cd
|
||||
private int _charSlot;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk1; // new in C4
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk2; // new in C4
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk3; // new in C4
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk4; // new in C4
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_charSlot = readD();
|
||||
_unk1 = readH();
|
||||
_unk2 = readD();
|
||||
_unk3 = readD();
|
||||
_unk4 = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (!client.getFloodProtectors().getCharacterSelect().tryPerformAction("CharacterSelect"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (SecondaryAuthData.getInstance().isEnabled() && !client.getSecondaryAuth().isAuthed())
|
||||
{
|
||||
client.getSecondaryAuth().openDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
// We should always be able to acquire the lock
|
||||
// But if we can't lock then nothing should be done (i.e. repeated packet)
|
||||
if (client.getActiveCharLock().tryLock())
|
||||
{
|
||||
try
|
||||
{
|
||||
// should always be null
|
||||
// but if not then this is repeated packet and nothing should be done here
|
||||
if (client.getActiveChar() == null)
|
||||
{
|
||||
final CharSelectInfoPackage info = client.getCharSelection(_charSlot);
|
||||
if (info == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Banned?
|
||||
if (PunishmentManager.getInstance().hasPunishment(info.getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.BAN) || PunishmentManager.getInstance().hasPunishment(client.getAccountName(), PunishmentAffect.ACCOUNT, PunishmentType.BAN) || PunishmentManager.getInstance().hasPunishment(client.getConnectionAddress().getHostAddress(), PunishmentAffect.IP, PunishmentType.BAN))
|
||||
{
|
||||
client.close(ServerClose.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Selected character is banned (compatibility with previous versions).
|
||||
if (info.getAccessLevel() < 0)
|
||||
{
|
||||
client.close(ServerClose.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Config.L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddClient(AntiFeedManager.GAME_ID, client, Config.L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP))
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(info.getHtmlPrefix(), "data/html/mods/IPRestriction.htm");
|
||||
msg.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(client, Config.L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP)));
|
||||
client.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// The L2PcInstance must be created here, so that it can be attached to the L2GameClient
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("selected slot:" + _charSlot);
|
||||
}
|
||||
|
||||
// load up character from disk
|
||||
final L2PcInstance cha = client.loadCharFromDisk(_charSlot);
|
||||
if (cha == null)
|
||||
{
|
||||
return; // handled in L2GameClient
|
||||
}
|
||||
|
||||
CharNameTable.getInstance().addName(cha);
|
||||
|
||||
cha.setClient(client);
|
||||
client.setActiveChar(cha);
|
||||
cha.setOnlineStatus(true, true);
|
||||
|
||||
final TerminateReturn terminate = EventDispatcher.getInstance().notifyEvent(new OnPlayerSelect(cha, cha.getObjectId(), cha.getName(), getClient()), Containers.Players(), TerminateReturn.class);
|
||||
if ((terminate != null) && terminate.terminate())
|
||||
{
|
||||
cha.deleteMe();
|
||||
return;
|
||||
}
|
||||
|
||||
client.setState(GameClientState.IN_GAME);
|
||||
sendPacket(new CharSelected(cha, client.getSessionId().playOkID1));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.getActiveCharLock().unlock();
|
||||
}
|
||||
|
||||
LogRecord record = new LogRecord(Level.INFO, "Logged in");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
client
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__12_CHARACTERSELECT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
import com.l2jserver.gameserver.enums.PlayerAction;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
import com.l2jserver.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jserver.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jserver.gameserver.model.holders.SummonRequestHolder;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
|
||||
/**
|
||||
* @author Dezmond_snz
|
||||
*/
|
||||
public final class DlgAnswer extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__C6_DLGANSWER = "[C] C6 DlgAnswer";
|
||||
private int _messageId;
|
||||
private int _answer;
|
||||
private int _requesterId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_messageId = readD();
|
||||
_answer = readD();
|
||||
_requesterId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TerminateReturn term = EventDispatcher.getInstance().notifyEvent(new OnPlayerDlgAnswer(activeChar, _messageId, _answer, _requesterId), activeChar, TerminateReturn.class);
|
||||
if ((term != null) && term.terminate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_messageId == SystemMessageId.S13.getId())
|
||||
{
|
||||
if (activeChar.removeAction(PlayerAction.USER_ENGAGE))
|
||||
{
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
{
|
||||
activeChar.engageAnswer(_answer);
|
||||
}
|
||||
}
|
||||
else if (activeChar.removeAction(PlayerAction.ADMIN_COMMAND))
|
||||
{
|
||||
String cmd = activeChar.getAdminConfirmCmd();
|
||||
activeChar.setAdminConfirmCmd(null);
|
||||
if (_answer == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String command = cmd.split(" ")[0];
|
||||
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
if (AdminTable.getInstance().hasAccess(command, activeChar.getAccessLevel()))
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
|
||||
}
|
||||
ach.useAdminCommand(cmd, activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((_messageId == SystemMessageId.C1_IS_ATTEMPTING_TO_DO_A_RESURRECTION_THAT_RESTORES_S2_S3_XP_ACCEPT.getId()) || (_messageId == SystemMessageId.YOUR_CHARM_OF_COURAGE_IS_TRYING_TO_RESURRECT_YOU_WOULD_YOU_LIKE_TO_RESURRECT_NOW.getId()))
|
||||
{
|
||||
activeChar.reviveAnswer(_answer);
|
||||
}
|
||||
else if (_messageId == SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId())
|
||||
{
|
||||
final SummonRequestHolder holder = activeChar.removeScript(SummonRequestHolder.class);
|
||||
if ((_answer == 1) && (holder != null) && (holder.getTarget().getObjectId() == _requesterId))
|
||||
{
|
||||
activeChar.teleToLocation(holder.getTarget().getLocation(), true);
|
||||
}
|
||||
}
|
||||
else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_OPEN_THE_GATE.getId())
|
||||
{
|
||||
final DoorRequestHolder holder = activeChar.removeScript(DoorRequestHolder.class);
|
||||
if ((holder != null) && (holder.getDoor() == activeChar.getTarget()) && (_answer == 1))
|
||||
{
|
||||
holder.getDoor().openMe();
|
||||
}
|
||||
}
|
||||
else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_CLOSE_THE_GATE.getId())
|
||||
{
|
||||
final DoorRequestHolder holder = activeChar.removeScript(DoorRequestHolder.class);
|
||||
if ((holder != null) && (holder.getDoor() == activeChar.getTarget()) && (_answer == 1))
|
||||
{
|
||||
holder.getDoor().closeMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__C6_DLGANSWER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* @author zabbix Lets drink to code!
|
||||
*/
|
||||
public final class DummyPacket extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "DummyPacket";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author JIV
|
||||
*/
|
||||
public final class EndScenePlayer extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_5B_ENDSCENEPLAYER = "[C] D0:5B EndScenePlayer";
|
||||
|
||||
private int _movieId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_movieId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_movieId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.getMovieId() != _movieId)
|
||||
{
|
||||
_log.warning("Player " + getClient() + " sent EndScenePlayer with wrong movie id: " + _movieId);
|
||||
return;
|
||||
}
|
||||
activeChar.setMovieId(0);
|
||||
activeChar.setIsTeleporting(true, false); // avoid to get player removed from L2World
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
activeChar.setIsTeleporting(false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_5B_ENDSCENEPLAYER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,701 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.LoginServerThread;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
import com.l2jserver.gameserver.datatables.AnnouncementsTable;
|
||||
import com.l2jserver.gameserver.datatables.BeautyShopData;
|
||||
import com.l2jserver.gameserver.datatables.SkillTreesData;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CoupleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.instancemanager.FortManager;
|
||||
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.instancemanager.MailManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.TeleportWhereType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ClassMasterInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
import com.l2jserver.gameserver.model.entity.Couple;
|
||||
import com.l2jserver.gameserver.model.entity.Fort;
|
||||
import com.l2jserver.gameserver.model.entity.FortSiege;
|
||||
import com.l2jserver.gameserver.model.entity.L2Event;
|
||||
import com.l2jserver.gameserver.model.entity.Siege;
|
||||
import com.l2jserver.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jserver.gameserver.model.entity.clanhall.AuctionableHall;
|
||||
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.Die;
|
||||
import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBeautyItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExCastleState;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExNewSkillToLearnByLevelUp;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExNoticePostArrived;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExNotifyPremiumItem;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPledgeCount;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowUsm;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExSubjobInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUnReadMailCount;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoEquipSlot;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExVitalityEffectInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExVoteSystemInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.HennaInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.QuestList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.friend.L2FriendList;
|
||||
|
||||
/**
|
||||
* Enter World Packet Handler
|
||||
* <p>
|
||||
* <p>
|
||||
* 0000: 03
|
||||
* <p>
|
||||
* packet format rev87 bddddbdcccccccccccccccccccc
|
||||
* <p>
|
||||
*/
|
||||
public class EnterWorld extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__11_ENTERWORLD = "[C] 11 EnterWorld";
|
||||
|
||||
private final int[][] tracert = new int[5][4];
|
||||
|
||||
@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
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int o = 0; o < 4; o++)
|
||||
{
|
||||
tracert[i][o] = readC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
_log.warning("EnterWorld failed! activeChar returned 'null'.");
|
||||
getClient().closeNow();
|
||||
return;
|
||||
}
|
||||
|
||||
String[] adress = new String[5];
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3];
|
||||
}
|
||||
|
||||
LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(), adress);
|
||||
|
||||
getClient().setClientTracert(tracert);
|
||||
|
||||
// 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 (L2World.getInstance().findObject(activeChar.getObjectId()) != null)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.warning("User already exists in Object ID map! User " + activeChar.getName() + " is a character clone.");
|
||||
}
|
||||
}
|
||||
|
||||
// Apply special GM properties to the GM when entering
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
if (Config.GM_STARTUP_INVULNERABLE && AdminTable.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_INVISIBLE && AdminTable.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setInvisible(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_SILENCE && AdminTable.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_DIET_MODE && AdminTable.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.refreshOverloaded();
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_AUTO_LIST && AdminTable.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
|
||||
{
|
||||
AdminTable.getInstance().addGm(activeChar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdminTable.getInstance().addGm(activeChar, true);
|
||||
}
|
||||
|
||||
if (Config.GM_GIVE_SPECIAL_SKILLS)
|
||||
{
|
||||
SkillTreesData.getInstance().addSkills(activeChar, false);
|
||||
}
|
||||
|
||||
if (Config.GM_GIVE_SPECIAL_AURA_SKILLS)
|
||||
{
|
||||
SkillTreesData.getInstance().addSkills(activeChar, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set dead status if applies
|
||||
if (activeChar.getCurrentHp() < 0.5)
|
||||
{
|
||||
activeChar.setIsDead(true);
|
||||
}
|
||||
|
||||
boolean showClanNotice = false;
|
||||
|
||||
// Clan related checks are here
|
||||
if (activeChar.getClan() != null)
|
||||
{
|
||||
notifyClanMembers(activeChar);
|
||||
|
||||
notifySponsorOrApprentice(activeChar);
|
||||
|
||||
AuctionableHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan());
|
||||
|
||||
if (clanHall != null)
|
||||
{
|
||||
if (!clanHall.getPaid())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_MAKE_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW);
|
||||
}
|
||||
}
|
||||
|
||||
for (Siege siege : SiegeManager.getInstance().getSieges())
|
||||
{
|
||||
if (!siege.isInProgress())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siege.checkIsAttacker(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 1);
|
||||
activeChar.setSiegeSide(siege.getCastle().getResidenceId());
|
||||
}
|
||||
|
||||
else if (siege.checkIsDefender(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 2);
|
||||
activeChar.setSiegeSide(siege.getCastle().getResidenceId());
|
||||
}
|
||||
}
|
||||
|
||||
for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
|
||||
{
|
||||
if (!siege.isInProgress())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siege.checkIsAttacker(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 1);
|
||||
activeChar.setSiegeSide(siege.getFort().getResidenceId());
|
||||
}
|
||||
|
||||
else if (siege.checkIsDefender(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 2);
|
||||
activeChar.setSiegeSide(siege.getFort().getResidenceId());
|
||||
}
|
||||
}
|
||||
|
||||
for (SiegableHall hall : CHSiegeManager.getInstance().getConquerableHalls().values())
|
||||
{
|
||||
if (!hall.isInSiege())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hall.isRegistered(activeChar.getClan()))
|
||||
{
|
||||
activeChar.setSiegeState((byte) 1);
|
||||
activeChar.setSiegeSide(hall.getId());
|
||||
activeChar.setIsInHideoutSiege(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Residential skills support
|
||||
if (activeChar.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
|
||||
}
|
||||
|
||||
if (activeChar.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
|
||||
}
|
||||
|
||||
showClanNotice = activeChar.getClan().isNoticeEnabled();
|
||||
}
|
||||
|
||||
if (Config.ENABLE_VITALITY)
|
||||
{
|
||||
activeChar.sendPacket(new ExVitalityEffectInfo(activeChar));
|
||||
}
|
||||
|
||||
// Send Macro List
|
||||
activeChar.getMacros().sendAllMacros();
|
||||
|
||||
// Send Teleport Bookmark List
|
||||
sendPacket(new ExGetBookMarkInfoPacket(activeChar));
|
||||
|
||||
// Send Item List
|
||||
sendPacket(new ItemList(activeChar, false));
|
||||
|
||||
// Send Shortcuts
|
||||
sendPacket(new ShortCutInit(activeChar));
|
||||
|
||||
// Send Action list
|
||||
activeChar.sendPacket(ExBasicActionList.STATIC_PACKET);
|
||||
|
||||
// Send blank skill list
|
||||
activeChar.sendPacket(new SkillList());
|
||||
|
||||
// Send castle state.
|
||||
for (Castle castle : CastleManager.getInstance().getCastles())
|
||||
{
|
||||
activeChar.sendPacket(new ExCastleState(castle));
|
||||
}
|
||||
|
||||
// Send GG check
|
||||
activeChar.queryGameGuard();
|
||||
|
||||
// Send Dye Information
|
||||
activeChar.sendPacket(new HennaInfo(activeChar));
|
||||
|
||||
// Send Skill list
|
||||
activeChar.sendSkillList();
|
||||
|
||||
// Send acquirable skill list
|
||||
activeChar.sendPacket(new AcquireSkillList(activeChar));
|
||||
|
||||
// Send EtcStatusUpdate
|
||||
activeChar.sendPacket(new EtcStatusUpdate(activeChar));
|
||||
|
||||
// Clan packets
|
||||
if (activeChar.getClan() != null)
|
||||
{
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
clan.broadcastToOnlineMembers(new PledgeShowMemberListUpdate(activeChar));
|
||||
sendPacket(new PledgeShowMemberListAll(clan));
|
||||
activeChar.sendPacket(new ExPledgeCount(clan));
|
||||
activeChar.sendPacket(new PledgeSkillList(clan));
|
||||
}
|
||||
|
||||
activeChar.broadcastUserInfo();
|
||||
|
||||
// Send SubClass Info
|
||||
activeChar.sendPacket(new ExSubjobInfo(activeChar));
|
||||
|
||||
// Send Inventory Info
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
|
||||
// Send Adena / Inventory Count Info
|
||||
activeChar.sendPacket(new ExAdenaInvenCount(activeChar));
|
||||
|
||||
// Send Equipped Items
|
||||
activeChar.sendPacket(new ExUserInfoEquipSlot(activeChar));
|
||||
|
||||
// Send Unread Mail Count
|
||||
if (MailManager.getInstance().hasUnreadPost(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(new ExUnReadMailCount(activeChar));
|
||||
}
|
||||
|
||||
Quest.playerEnter(activeChar);
|
||||
|
||||
// Send Quest List
|
||||
activeChar.sendPacket(new QuestList());
|
||||
|
||||
if (Config.PLAYER_SPAWN_PROTECTION > 0)
|
||||
{
|
||||
activeChar.setProtection(true);
|
||||
}
|
||||
|
||||
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
|
||||
activeChar.getInventory().applyItemSkills();
|
||||
|
||||
if (L2Event.isParticipant(activeChar))
|
||||
{
|
||||
L2Event.restorePlayerEventStatus(activeChar);
|
||||
}
|
||||
|
||||
// Wedding Checks
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
{
|
||||
engage(activeChar);
|
||||
notifyPartner(activeChar, activeChar.getPartnerId());
|
||||
}
|
||||
|
||||
if (activeChar.isCursedWeaponEquipped())
|
||||
{
|
||||
CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
|
||||
}
|
||||
|
||||
activeChar.updateEffectIcons();
|
||||
|
||||
// Expand Skill
|
||||
activeChar.sendPacket(new ExStorageMaxCount(activeChar));
|
||||
|
||||
// Friend list
|
||||
sendPacket(new L2FriendList(activeChar));
|
||||
|
||||
if (Config.SHOW_GOD_VIDEO_INTRO && activeChar.getVariables().getBoolean("intro_god_video", false))
|
||||
{
|
||||
activeChar.getVariables().remove("intro_god_video");
|
||||
if (activeChar.getRace() == Race.ERTHEIA)
|
||||
{
|
||||
activeChar.sendPacket(ExShowUsm.ERTHEIA_INTRO_FOR_ERTHEIA);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(ExShowUsm.ERTHEIA_INTRO_FOR_OTHERS);
|
||||
}
|
||||
}
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_FRIEND_S1_JUST_LOGGED_IN);
|
||||
sm.addString(activeChar.getName());
|
||||
for (int id : activeChar.getFriendList())
|
||||
{
|
||||
L2Object obj = L2World.getInstance().findObject(id);
|
||||
if (obj != null)
|
||||
{
|
||||
obj.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendPacket(SystemMessageId.WELCOME_TO_THE_WORLD_OF_LINEAGE_II);
|
||||
|
||||
activeChar.sendMessage(getText("VGhpcyBTZXJ2ZXIgdXNlcyBMMkosIGEgUHJvamVjdCBmb3VuZGVkIGJ5IEwyQ2hlZg=="));
|
||||
activeChar.sendMessage(getText("YW5kIGRldmVsb3BlZCBieSBMMkogVGVhbSBhdCB3d3cubDJqc2VydmVyLmNvbQ=="));
|
||||
activeChar.sendMessage(getText("Q29weXJpZ2h0IDIwMDQtMjAxNA=="));
|
||||
activeChar.sendMessage(getText("VGhhbmsgeW91IGZvciAxMCB5ZWFycyE="));
|
||||
|
||||
AnnouncementsTable.getInstance().showAnnouncements(activeChar);
|
||||
|
||||
if (showClanNotice)
|
||||
{
|
||||
final NpcHtmlMessage notice = new NpcHtmlMessage();
|
||||
notice.setFile(activeChar.getHtmlPrefix(), "data/html/clanNotice.htm");
|
||||
notice.replace("%clan_name%", activeChar.getClan().getName());
|
||||
notice.replace("%notice_text%", activeChar.getClan().getNotice());
|
||||
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(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));
|
||||
}
|
||||
|
||||
activeChar.onPlayerEnter();
|
||||
|
||||
sendPacket(new SkillCoolTime(activeChar));
|
||||
sendPacket(new ExVoteSystemInfo(activeChar));
|
||||
|
||||
for (L2ItemInstance i : activeChar.getInventory().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem())
|
||||
{
|
||||
i.scheduleLifeTimeTask();
|
||||
}
|
||||
if (i.isShadowItem() && i.isEquipped())
|
||||
{
|
||||
i.decreaseMana(false);
|
||||
}
|
||||
}
|
||||
|
||||
for (L2ItemInstance i : activeChar.getWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem())
|
||||
{
|
||||
i.scheduleLifeTimeTask();
|
||||
}
|
||||
}
|
||||
|
||||
if (activeChar.getClanJoinExpiryTime() > System.currentTimeMillis())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_RECENTLY_BEEN_DISMISSED_FROM_A_CLAN_YOU_ARE_NOT_ALLOWED_TO_JOIN_ANOTHER_CLAN_FOR_24_HOURS);
|
||||
}
|
||||
|
||||
// remove combat flag before teleporting
|
||||
if (activeChar.getInventory().getItemByItemId(9819) != null)
|
||||
{
|
||||
final Fort fort = FortManager.getInstance().getFort(activeChar);
|
||||
if (fort != null)
|
||||
{
|
||||
FortSiegeManager.getInstance().dropCombatFlag(activeChar, fort.getResidenceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819));
|
||||
activeChar.getInventory().unEquipItemInBodySlot(slot);
|
||||
activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Attacker or spectator logging in to a siege zone.
|
||||
// Actually should be checked for inside castle only?
|
||||
if (!activeChar.canOverrideCond(PcCondOverride.ZONE_CONDITIONS) && activeChar.isInsideZone(ZoneId.SIEGE) && (!activeChar.isInSiege() || (activeChar.getSiegeState() < 2)))
|
||||
{
|
||||
activeChar.teleToLocation(TeleportWhereType.TOWN);
|
||||
}
|
||||
|
||||
if (Config.ALLOW_MAIL)
|
||||
{
|
||||
if (MailManager.getInstance().hasUnreadPost(activeChar))
|
||||
{
|
||||
sendPacket(ExNoticePostArrived.valueOf(false));
|
||||
}
|
||||
}
|
||||
|
||||
TvTEvent.onLogin(activeChar);
|
||||
|
||||
if (Config.WELCOME_MESSAGE_ENABLED)
|
||||
{
|
||||
activeChar.sendPacket(new ExShowScreenMessage(Config.WELCOME_MESSAGE_TEXT, Config.WELCOME_MESSAGE_TIME));
|
||||
}
|
||||
|
||||
L2ClassMasterInstance.showQuestionMark(activeChar);
|
||||
|
||||
int birthday = activeChar.checkBirthDay();
|
||||
if (birthday == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.HAPPY_BIRTHDAY_ALEGRIA_HAS_SENT_YOU_A_BIRTHDAY_GIFT);
|
||||
// activeChar.sendPacket(new ExBirthdayPopup()); Removed in H5?
|
||||
}
|
||||
else if (birthday != -1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_REMAINING_UNTIL_YOUR_BIRTHDAY_ON_YOUR_BIRTHDAY_YOU_WILL_RECEIVE_A_GIFT_THAT_ALEGRIA_HAS_CAREFULLY_PREPARED);
|
||||
sm.addString(Integer.toString(birthday));
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (!activeChar.getPremiumItemList().isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(ExNotifyPremiumItem.STATIC_PACKET);
|
||||
}
|
||||
|
||||
activeChar.broadcastUserInfo();
|
||||
|
||||
if (BeautyShopData.getInstance().hasBeautyData(activeChar.getRace(), activeChar.getAppearance().getSexType()))
|
||||
{
|
||||
activeChar.sendPacket(new ExBeautyItemList(activeChar));
|
||||
}
|
||||
|
||||
if (SkillTreesData.getInstance().hasAvailableSkills(activeChar, activeChar.getClassId()))
|
||||
{
|
||||
activeChar.sendPacket(ExNewSkillToLearnByLevelUp.STATIC_PACKET);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cha
|
||||
*/
|
||||
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.setMarried(true);
|
||||
}
|
||||
|
||||
cha.setCoupleId(cl.getId());
|
||||
|
||||
if (cl.getPlayer1Id() == chaId)
|
||||
{
|
||||
cha.setPartnerId(cl.getPlayer2Id());
|
||||
}
|
||||
else
|
||||
{
|
||||
cha.setPartnerId(cl.getPlayer1Id());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cha
|
||||
* @param partnerId
|
||||
*/
|
||||
private void notifyPartner(L2PcInstance cha, int partnerId)
|
||||
{
|
||||
int objId = cha.getPartnerId();
|
||||
if (objId != 0)
|
||||
{
|
||||
final L2PcInstance partner = L2World.getInstance().getPlayer(objId);
|
||||
if (partner != null)
|
||||
{
|
||||
partner.sendMessage("Your Partner has logged in.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void notifyClanMembers(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
if (clan != null)
|
||||
{
|
||||
clan.getClanMember(activeChar.getObjectId()).setPlayerInstance(activeChar);
|
||||
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.CLAN_MEMBER_S1_HAS_LOGGED_INTO_GAME);
|
||||
msg.addString(activeChar.getName());
|
||||
clan.broadcastToOtherOnlineMembers(msg, activeChar);
|
||||
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(activeChar), activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void notifySponsorOrApprentice(L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar.getSponsor() != 0)
|
||||
{
|
||||
final L2PcInstance sponsor = L2World.getInstance().getPlayer(activeChar.getSponsor());
|
||||
if (sponsor != null)
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN);
|
||||
msg.addString(activeChar.getName());
|
||||
sponsor.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else if (activeChar.getApprentice() != 0)
|
||||
{
|
||||
final L2PcInstance apprentice = L2World.getInstance().getPlayer(activeChar.getApprentice());
|
||||
if (apprentice != null)
|
||||
{
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOUR_SPONSOR_C1_HAS_LOGGED_IN);
|
||||
msg.addString(activeChar.getName());
|
||||
apprentice.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
private String getText(String string)
|
||||
{
|
||||
return new String(Base64.getDecoder().decode(string));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__11_ENTERWORLD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* Format: (c) dddd d: dx d: dy d: dz d: AirShip id ??
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class ExGetOnAirShip extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_36_EXGETONAIRSHIP = "[C] D0:36 ExGetOnAirShip";
|
||||
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
private int _shipId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
_shipId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
_log.info("[T1:ExGetOnAirShip] x: " + _x);
|
||||
_log.info("[T1:ExGetOnAirShip] y: " + _y);
|
||||
_log.info("[T1:ExGetOnAirShip] z: " + _z);
|
||||
_log.info("[T1:ExGetOnAirShip] ship ID: " + _shipId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_36_EXGETONAIRSHIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StopRotation;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class FinishRotating extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__5C_FINISHROTATING = "[C] 5C FinishRotating";
|
||||
|
||||
private int _degree;
|
||||
@SuppressWarnings("unused")
|
||||
private int _unknown;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_degree = readD();
|
||||
_unknown = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StopRotation sr;
|
||||
if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar))
|
||||
{
|
||||
activeChar.getAirShip().setHeading(_degree);
|
||||
sr = new StopRotation(activeChar.getAirShip().getObjectId(), _degree, 0);
|
||||
activeChar.getAirShip().broadcastPacket(sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sr = new StopRotation(activeChar.getObjectId(), _degree, 0);
|
||||
activeChar.broadcastPacket(sr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__5C_FINISHROTATING;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
|
||||
/**
|
||||
* Format: c dddd
|
||||
* @author KenM
|
||||
*/
|
||||
public class GameGuardReply extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__CB_GAMEGUARDREPLY = "[C] CB GameGuardReply";
|
||||
|
||||
private static final byte[] VALID =
|
||||
{
|
||||
(byte) 0x88,
|
||||
0x40,
|
||||
0x1c,
|
||||
(byte) 0xa7,
|
||||
(byte) 0x83,
|
||||
0x42,
|
||||
(byte) 0xe9,
|
||||
0x15,
|
||||
(byte) 0xde,
|
||||
(byte) 0xc3,
|
||||
0x68,
|
||||
(byte) 0xf6,
|
||||
0x2d,
|
||||
0x23,
|
||||
(byte) 0xf1,
|
||||
0x3f,
|
||||
(byte) 0xee,
|
||||
0x68,
|
||||
0x5b,
|
||||
(byte) 0xc5,
|
||||
};
|
||||
|
||||
private final byte[] _reply = new byte[8];
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
readB(_reply, 0, 4);
|
||||
readD();
|
||||
readB(_reply, 4, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2GameClient client = getClient();
|
||||
try
|
||||
{
|
||||
MessageDigest md = MessageDigest.getInstance("SHA");
|
||||
byte[] result = md.digest(_reply);
|
||||
if (Arrays.equals(result, VALID))
|
||||
{
|
||||
client.setGameGuardOk(true);
|
||||
}
|
||||
}
|
||||
catch (NoSuchAlgorithmException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__CB_GAMEGUARDREPLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.mmocore.network.ReceivablePacket;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Packets received by the game server from clients
|
||||
* @author KenM
|
||||
*/
|
||||
public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(L2GameClientPacket.class.getName());
|
||||
|
||||
@Override
|
||||
public boolean read()
|
||||
{
|
||||
try
|
||||
{
|
||||
readImpl();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Client: " + getClient().toString() + " - Failed reading: " + getType() + " ; " + e.getMessage(), e);
|
||||
|
||||
if (e instanceof BufferUnderflowException)
|
||||
{
|
||||
getClient().onBufferUnderflow();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void readImpl();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
runImpl();
|
||||
|
||||
/*
|
||||
* Removes onspawn protection - player has faster computer than average Since GE: True for all packets except RequestItemList and UseItem (in case the item is a Scroll of Escape (736)
|
||||
*/
|
||||
if (triggersOnActionRequest())
|
||||
{
|
||||
final L2PcInstance actor = getClient().getActiveChar();
|
||||
if ((actor != null) && (actor.isSpawnProtected() || actor.isInvul()))
|
||||
{
|
||||
actor.onActionRequest();
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Spawn protection for player " + actor.getName() + " removed by packet: " + getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Client: " + getClient().toString() + " - Failed running: " + getType() + " ; " + t.getMessage(), t);
|
||||
// in case of EnterWorld error kick player from game
|
||||
if (this instanceof EnterWorld)
|
||||
{
|
||||
getClient().closeNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void runImpl();
|
||||
|
||||
/**
|
||||
* Sends a game server packet to the client.
|
||||
* @param gsp the game server packet
|
||||
*/
|
||||
protected final void sendPacket(L2GameServerPacket gsp)
|
||||
{
|
||||
getClient().sendPacket(gsp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a system message to the client.
|
||||
* @param id the system message Id
|
||||
*/
|
||||
public void sendPacket(SystemMessageId id)
|
||||
{
|
||||
sendPacket(SystemMessage.getSystemMessage(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A String with this packet name for debugging purposes
|
||||
*/
|
||||
public abstract String getType();
|
||||
|
||||
/**
|
||||
* Overridden with true value on some packets that should disable spawn protection (RequestItemList and UseItem only)
|
||||
* @return
|
||||
*/
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active player if exist, otherwise null.
|
||||
*/
|
||||
protected final L2PcInstance getActiveChar()
|
||||
{
|
||||
return getClient().getActiveChar();
|
||||
}
|
||||
|
||||
protected final void sendActionFailed()
|
||||
{
|
||||
if (getClient() != null)
|
||||
{
|
||||
getClient().sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.L2Event;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.9.4.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class Logout extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__00_LOGOUT = "[C] 00 Logout";
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((player.getActiveEnchantItemId() != L2PcInstance.ID_NONE) || (player.getActiveEnchantAttrItemId() != L2PcInstance.ID_NONE))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Player " + player.getName() + " tried to logout while enchanting.");
|
||||
}
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isLocked())
|
||||
{
|
||||
_log.warning("Player " + player.getName() + " tried to logout during class change.");
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't allow leaving if player is fighting
|
||||
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player))
|
||||
{
|
||||
if (player.isGM() && Config.GM_RESTART_FIGHTING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Player " + player.getName() + " tried to logout while fighting.");
|
||||
}
|
||||
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_EXIT_THE_GAME_WHILE_IN_COMBAT);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (L2Event.isParticipant(player))
|
||||
{
|
||||
player.sendMessage("A superior power doesn't allow you to leave the event.");
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove player from Boss Zone
|
||||
player.removeFromBossZone();
|
||||
|
||||
LogRecord record = new LogRecord(Level.INFO, "Disconnected");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
getClient()
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
|
||||
player.logout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__00_LOGOUT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StopMove;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.11.2.4.2.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public class MoveBackwardToLocation extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0F_MOVEBACKWARDTOLOC = "[C] 0F MoveBackwardToLoc";
|
||||
|
||||
// cdddddd
|
||||
private int _targetX;
|
||||
private int _targetY;
|
||||
private int _targetZ;
|
||||
private int _originX;
|
||||
private int _originY;
|
||||
private int _originZ;
|
||||
private int _moveMovement;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_targetX = readD();
|
||||
_targetY = readD();
|
||||
_targetZ = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
try
|
||||
{
|
||||
_moveMovement = readD(); // is 0 if cursor keys are used 1 if mouse is used
|
||||
}
|
||||
catch (BufferUnderflowException e)
|
||||
{
|
||||
if (Config.L2WALKER_PROTECTION)
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is trying to use L2Walker and got kicked.", Config.DEFAULT_PUNISH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM() && (activeChar.getNotMoveUntil() > System.currentTimeMillis()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_MOVE_WHILE_SPEAKING_TO_AN_NPC_ONE_MOMENT_PLEASE);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_targetX == _originX) && (_targetY == _originY) && (_targetZ == _originZ))
|
||||
{
|
||||
activeChar.sendPacket(new StopMove(activeChar));
|
||||
return;
|
||||
}
|
||||
|
||||
// Correcting targetZ from floor level to head level (?)
|
||||
// Client is giving floor level as targetZ but that floor level doesn't
|
||||
// match our current geodata and teleport coords as good as head level!
|
||||
// L2J uses floor, not head level as char coordinates. This is some
|
||||
// sort of incompatibility fix.
|
||||
// Validate position packets sends head level.
|
||||
_targetZ += activeChar.getTemplate().getCollisionHeight();
|
||||
|
||||
if (activeChar.getTeleMode() > 0)
|
||||
{
|
||||
if (activeChar.getTeleMode() == 1)
|
||||
{
|
||||
activeChar.setTeleMode(0);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.teleToLocation(new Location(_targetX, _targetY, _targetZ));
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable keyboard movement when geodata is not enabled and player is not flying.
|
||||
if ((_moveMovement == 0) && (Config.GEODATA < 1) && !activeChar.isFlying())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
double dx = _targetX - activeChar.getX();
|
||||
double dy = _targetY - activeChar.getY();
|
||||
// Can't move if character is confused, or trying to move a huge distance
|
||||
if (activeChar.isOutOfControl() || (((dx * dx) + (dy * dy)) > 98010000)) // 9900*9900
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_targetX, _targetY, _targetZ));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0F_MOVEBACKWARDTOLOC;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.instancemanager.AirShipManager;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.VehiclePathPoint;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public class MoveToLocationAirShip extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_38_MOVETOLOCATIONAIRSHIP = "[C] D0:38 MoveToLocationAirShip";
|
||||
|
||||
public static final int MIN_Z = -895;
|
||||
public static final int MAX_Z = 6105;
|
||||
public static final int STEP = 300;
|
||||
|
||||
private int _command;
|
||||
private int _param1;
|
||||
private int _param2 = 0;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_command = readD();
|
||||
_param1 = readD();
|
||||
if (_buf.remaining() > 0)
|
||||
{
|
||||
_param2 = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInAirShip())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2AirShipInstance ship = activeChar.getAirShip();
|
||||
if (!ship.isCaptain(activeChar))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int z = ship.getZ();
|
||||
|
||||
switch (_command)
|
||||
{
|
||||
case 0:
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_param1 < L2World.GRACIA_MAX_X)
|
||||
{
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(_param1, _param2, z));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
|
||||
break;
|
||||
case 2:
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (z < L2World.GRACIA_MAX_Z)
|
||||
{
|
||||
z = Math.min(z + STEP, L2World.GRACIA_MAX_Z);
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(ship.getX(), ship.getY(), z));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!ship.canBeControlled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (z > L2World.GRACIA_MIN_Z)
|
||||
{
|
||||
z = Math.max(z - STEP, L2World.GRACIA_MIN_Z);
|
||||
ship.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(ship.getX(), ship.getY(), z));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (!ship.isInDock() || ship.isMoving())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final VehiclePathPoint[] dst = AirShipManager.getInstance().getTeleportDestination(ship.getDockId(), _param1);
|
||||
if (dst == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Consume fuel, if needed
|
||||
final int fuelConsumption = AirShipManager.getInstance().getFuelConsumption(ship.getDockId(), _param1);
|
||||
if (fuelConsumption > 0)
|
||||
{
|
||||
if (fuelConsumption > ship.getFuel())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_AIRSHIP_CANNOT_TELEPORT_BECAUSE_DUE_TO_LOW_FUEL);
|
||||
return;
|
||||
}
|
||||
ship.setFuel(ship.getFuel() - fuelConsumption);
|
||||
}
|
||||
|
||||
ship.executePath(dst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_38_MOVETOLOCATIONAIRSHIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.WeaponType;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExMoveToLocationInAirShip;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StopMoveInVehicle;
|
||||
|
||||
/**
|
||||
* format: ddddddd X:%d Y:%d Z:%d OriginX:%d OriginY:%d OriginZ:%d
|
||||
* @author GodKratos
|
||||
*/
|
||||
public class MoveToLocationInAirShip extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_20_MOVETOLOCATIONINAIRSHIP = "[C] D0:20 MoveToLocationInAirShip";
|
||||
|
||||
private int _shipId;
|
||||
private int _targetX;
|
||||
private int _targetY;
|
||||
private int _targetZ;
|
||||
private int _originX;
|
||||
private int _originY;
|
||||
private int _originZ;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_shipId = readD();
|
||||
_targetX = readD();
|
||||
_targetY = readD();
|
||||
_targetZ = readD();
|
||||
_originX = readD();
|
||||
_originY = readD();
|
||||
_originZ = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_targetX == _originX) && (_targetY == _originY) && (_targetZ == _originZ))
|
||||
{
|
||||
activeChar.sendPacket(new StopMoveInVehicle(activeChar, _shipId));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isAttackingNow() && (activeChar.getActiveWeaponItem() != null) && (activeChar.getActiveWeaponItem().getItemType() == WeaponType.BOW))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isSitting() || activeChar.isMovementDisabled())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInAirShip())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2AirShipInstance airShip = activeChar.getAirShip();
|
||||
if (airShip.getObjectId() != _shipId)
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.setInVehiclePosition(new Location(_targetX, _targetY, _targetZ));
|
||||
activeChar.broadcastPacket(new ExMoveToLocationInAirShip(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_20_MOVETOLOCATIONINAIRSHIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* Format: (c) ddd d: dx d: dy d: dz
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class MoveWithDelta extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__52_MOVEWITHDELTA = "[C] 52 MoveWithDelta";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int _dx;
|
||||
@SuppressWarnings("unused")
|
||||
private int _dy;
|
||||
@SuppressWarnings("unused")
|
||||
private int _dz;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_dx = readD();
|
||||
_dy = readD();
|
||||
_dz = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// TODO this
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__52_MOVEWITHDELTA;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.MultisellData;
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2Augmentation;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.multisell.Entry;
|
||||
import com.l2jserver.gameserver.model.multisell.Ingredient;
|
||||
import com.l2jserver.gameserver.model.multisell.PreparedListContainer;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* The Class MultiSellChoose.
|
||||
*/
|
||||
public class MultiSellChoose extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__B0_MULTISELLCHOOSE = "[C] B0 MultiSellChoose";
|
||||
|
||||
private int _listId;
|
||||
private int _entryId;
|
||||
private long _amount;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_listId = readD();
|
||||
_entryId = readD();
|
||||
_amount = readQ();
|
||||
// _unk1 = readH();
|
||||
// _unk2 = readD();
|
||||
// _unk3 = readD();
|
||||
// _unk4 = readH(); // elemental attributes
|
||||
// _unk5 = readH(); // elemental attributes
|
||||
// _unk6 = readH(); // elemental attributes
|
||||
// _unk7 = readH(); // elemental attributes
|
||||
// _unk8 = readH(); // elemental attributes
|
||||
// _unk9 = readH(); // elemental attributes
|
||||
// _unk10 = readH(); // elemental attributes
|
||||
// _unk11 = readH(); // elemental attributes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getMultiSell().tryPerformAction("multisell choose"))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_amount < 1) || (_amount > 5000))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
PreparedListContainer list = player.getMultiSell();
|
||||
if ((list == null) || (list.getListId() != _listId))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc npc = player.getLastFolkNPC();
|
||||
if (((npc != null) && !list.isNpcAllowed(npc.getId())) || ((npc == null) && list.isNpcOnly()))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entry entry : list.getEntries())
|
||||
{
|
||||
if (entry.getEntryId() == _entryId)
|
||||
{
|
||||
if (!entry.isStackable() && (_amount > 1))
|
||||
{
|
||||
_log.severe("Character: " + player.getName() + " is trying to set amount > 1 on non-stackable multisell, id:" + _listId + ":" + _entryId);
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final PcInventory inv = player.getInventory();
|
||||
|
||||
int slots = 0;
|
||||
int weight = 0;
|
||||
for (Ingredient e : entry.getProducts())
|
||||
{
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!e.isStackable())
|
||||
{
|
||||
slots += e.getItemCount() * _amount;
|
||||
}
|
||||
else if (player.getInventory().getItemByItemId(e.getItemId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
weight += e.getItemCount() * _amount * e.getWeight();
|
||||
}
|
||||
|
||||
if (!inv.validateWeight(weight))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inv.validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Ingredient> ingredientsList = new ArrayList<>(entry.getIngredients().size());
|
||||
// Generate a list of distinct ingredients and counts in order to check if the correct item-counts
|
||||
// are possessed by the player
|
||||
boolean newIng;
|
||||
for (Ingredient e : entry.getIngredients())
|
||||
{
|
||||
newIng = true;
|
||||
// at this point, the template has already been modified so that enchantments are properly included
|
||||
// whenever they need to be applied. Uniqueness of items is thus judged by item id AND enchantment level
|
||||
for (int i = ingredientsList.size(); --i >= 0;)
|
||||
{
|
||||
Ingredient ex = ingredientsList.get(i);
|
||||
// if the item was already added in the list, merely increment the count
|
||||
// this happens if 1 list entry has the same ingredient twice (example 2 swords = 1 dual)
|
||||
if ((ex.getItemId() == e.getItemId()) && (ex.getEnchantLevel() == e.getEnchantLevel()))
|
||||
{
|
||||
if ((ex.getItemCount() + e.getItemCount()) > Integer.MAX_VALUE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
|
||||
return;
|
||||
}
|
||||
// two same ingredients, merge into one and replace old
|
||||
final Ingredient ing = ex.getCopy();
|
||||
ing.setItemCount(ex.getItemCount() + e.getItemCount());
|
||||
ingredientsList.set(i, ing);
|
||||
newIng = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newIng)
|
||||
{
|
||||
// if it's a new ingredient, just store its info directly (item id, count, enchantment)
|
||||
ingredientsList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
// now check if the player has sufficient items in the inventory to cover the ingredients' expences
|
||||
for (Ingredient e : ingredientsList)
|
||||
{
|
||||
if ((e.getItemCount() * _amount) > Integer.MAX_VALUE)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
|
||||
return;
|
||||
}
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
if (!MultisellData.hasSpecialIngredient(e.getItemId(), e.getItemCount() * _amount, player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if this is not a list that maintains enchantment, check the count of all items that have the given id.
|
||||
// otherwise, check only the count of items with exactly the needed enchantment level
|
||||
final long required = ((Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient()) ? (e.getItemCount() * _amount) : e.getItemCount());
|
||||
if (inv.getInventoryItemCount(e.getItemId(), list.getMaintainEnchantment() ? e.getEnchantLevel() : -1, false) < required)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
|
||||
sm.addItemName(e.getTemplate());
|
||||
sm.addLong(required);
|
||||
player.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FastList<L2Augmentation> augmentation = FastList.newInstance();
|
||||
Elementals[] elemental = null;
|
||||
/** All ok, remove items and add final product */
|
||||
|
||||
try
|
||||
{
|
||||
for (Ingredient e : entry.getIngredients())
|
||||
{
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
if (!MultisellData.takeSpecialIngredient(e.getItemId(), e.getItemCount() * _amount, player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
L2ItemInstance itemToTake = inv.getItemByItemId(e.getItemId()); // initialize and initial guess for the item to take.
|
||||
if (itemToTake == null)
|
||||
{ // this is a cheat, transaction will be aborted and if any items already taken will not be returned back to inventory!
|
||||
_log.severe("Character: " + player.getName() + " is trying to cheat in multisell, id:" + _listId + ":" + _entryId);
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (itemToTake.isEquipped())
|
||||
// {
|
||||
// this is a cheat, transaction will be aborted and if any items already taken will not be returned back to inventory!
|
||||
// _log.severe("Character: " + player.getName() + " is trying to cheat in multisell, exchanging equipped item, merchatnt id:" + merchant.getNpcId());
|
||||
// player.setMultiSell(null);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient())
|
||||
{
|
||||
// if it's a stackable item, just reduce the amount from the first (only) instance that is found in the inventory
|
||||
if (itemToTake.isStackable())
|
||||
{
|
||||
if (!player.destroyItem("Multisell", itemToTake.getObjectId(), (e.getItemCount() * _amount), player.getTarget(), true))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// for non-stackable items, one of two scenaria are possible:
|
||||
// a) list maintains enchantment: get the instances that exactly match the requested enchantment level
|
||||
// b) list does not maintain enchantment: get the instances with the LOWEST enchantment level
|
||||
|
||||
// a) if enchantment is maintained, then get a list of items that exactly match this enchantment
|
||||
if (list.getMaintainEnchantment())
|
||||
{
|
||||
// loop through this list and remove (one by one) each item until the required amount is taken.
|
||||
L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantLevel(), false);
|
||||
for (int i = 0; i < (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
if (inventoryContents[i].isAugmented())
|
||||
{
|
||||
augmentation.add(inventoryContents[i].getAugmentation());
|
||||
}
|
||||
if (inventoryContents[i].getElementals() != null)
|
||||
{
|
||||
elemental = inventoryContents[i].getElementals();
|
||||
}
|
||||
if (!player.destroyItem("Multisell", inventoryContents[i].getObjectId(), 1, player.getTarget(), true))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// b) enchantment is not maintained. Get the instances with the LOWEST enchantment level
|
||||
{
|
||||
// NOTE: There are 2 ways to achieve the above goal.
|
||||
// 1) Get all items that have the correct itemId, loop through them until the lowest enchantment
|
||||
// level is found. Repeat all this for the next item until proper count of items is reached.
|
||||
// 2) Get all items that have the correct itemId, sort them once based on enchantment level,
|
||||
// and get the range of items that is necessary.
|
||||
// Method 1 is faster for a small number of items to be exchanged.
|
||||
// Method 2 is faster for large amounts.
|
||||
//
|
||||
// EXPLANATION:
|
||||
// Worst case scenario for algorithm 1 will make it run in a number of cycles given by:
|
||||
// m*(2n-m+1)/2 where m is the number of items to be exchanged and n is the total
|
||||
// number of inventory items that have a matching id.
|
||||
// With algorithm 2 (sort), sorting takes n*log(n) time and the choice is done in a single cycle
|
||||
// for case b (just grab the m first items) or in linear time for case a (find the beginning of items
|
||||
// with correct enchantment, index x, and take all items from x to x+m).
|
||||
// Basically, whenever m > log(n) we have: m*(2n-m+1)/2 = (2nm-m*m+m)/2 >
|
||||
// (2nlogn-logn*logn+logn)/2 = nlog(n) - log(n*n) + log(n) = nlog(n) + log(n/n*n) =
|
||||
// nlog(n) + log(1/n) = nlog(n) - log(n) = (n-1)log(n)
|
||||
// So for m < log(n) then m*(2n-m+1)/2 > (n-1)log(n) and m*(2n-m+1)/2 > nlog(n)
|
||||
//
|
||||
// IDEALLY:
|
||||
// In order to best optimize the performance, choose which algorithm to run, based on whether 2^m > n
|
||||
// if ( (2<<(e.getItemCount()// _amount)) < inventoryContents.length )
|
||||
// // do Algorithm 1, no sorting
|
||||
// else
|
||||
// // do Algorithm 2, sorting
|
||||
//
|
||||
// CURRENT IMPLEMENTATION:
|
||||
// In general, it is going to be very rare for a person to do a massive exchange of non-stackable items
|
||||
// For this reason, we assume that algorithm 1 will always suffice and we keep things simple.
|
||||
// If, in the future, it becomes necessary that we optimize, the above discussion should make it clear
|
||||
// what optimization exactly is necessary (based on the comments under "IDEALLY").
|
||||
//
|
||||
|
||||
// choice 1. Small number of items exchanged. No sorting.
|
||||
for (int i = 1; i <= (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), false);
|
||||
|
||||
itemToTake = inventoryContents[0];
|
||||
// get item with the LOWEST enchantment level from the inventory...
|
||||
// +0 is lowest by default...
|
||||
if (itemToTake.getEnchantLevel() > 0)
|
||||
{
|
||||
for (L2ItemInstance item : inventoryContents)
|
||||
{
|
||||
if (item.getEnchantLevel() < itemToTake.getEnchantLevel())
|
||||
{
|
||||
itemToTake = item;
|
||||
// nothing will have enchantment less than 0. If a zero-enchanted
|
||||
// item is found, just take it
|
||||
if (itemToTake.getEnchantLevel() == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!player.destroyItem("Multisell", itemToTake.getObjectId(), 1, player.getTarget(), true))
|
||||
{
|
||||
player.setMultiSell(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final double itemRandom = 100 * Rnd.nextDouble();
|
||||
float cumulativeChance = 0;
|
||||
|
||||
boolean matched = false;
|
||||
// Generate the appropriate items
|
||||
for (Ingredient e : entry.getProducts())
|
||||
{
|
||||
if (list.isNewMultisell())
|
||||
{
|
||||
// Skip first entry.
|
||||
if (e.getChance() < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate chance
|
||||
matched = (itemRandom < (cumulativeChance += e.getChance()));
|
||||
if (!matched)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.getItemId() < 0)
|
||||
{
|
||||
MultisellData.giveSpecialProduct(e.getItemId(), e.getItemCount() * _amount, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.isStackable())
|
||||
{
|
||||
inv.addItem("Multisell", e.getItemId(), e.getItemCount() * _amount, player, player.getTarget());
|
||||
}
|
||||
else
|
||||
{
|
||||
L2ItemInstance product = null;
|
||||
for (int i = 0; i < (e.getItemCount() * _amount); i++)
|
||||
{
|
||||
product = inv.addItem("Multisell", e.getItemId(), 1, player, player.getTarget());
|
||||
if ((product != null) && list.getMaintainEnchantment())
|
||||
{
|
||||
if (i < augmentation.size())
|
||||
{
|
||||
product.setAugmentation(new L2Augmentation(augmentation.get(i).getAugmentationId()));
|
||||
}
|
||||
if (elemental != null)
|
||||
{
|
||||
for (Elementals elm : elemental)
|
||||
{
|
||||
product.setElementAttr(elm.getElement(), elm.getValue());
|
||||
}
|
||||
}
|
||||
product.setEnchantLevel(e.getEnchantLevel());
|
||||
product.updateDatabase();
|
||||
}
|
||||
}
|
||||
}
|
||||
// msg part
|
||||
SystemMessage sm;
|
||||
|
||||
if ((e.getItemCount() * _amount) > 1)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
|
||||
sm.addItemName(e.getItemId());
|
||||
sm.addLong(e.getItemCount() * _amount);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.getMaintainEnchantment() && (e.getEnchantLevel() > 0))
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ACQUIRED_S1_S2);
|
||||
sm.addLong(e.getEnchantLevel());
|
||||
sm.addItemName(e.getItemId());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
|
||||
sm.addItemName(e.getItemId());
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
if (matched)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.sendPacket(new ItemList(player, false));
|
||||
player.sendPacket(new ExUserInfoInvenWeight(player));
|
||||
}
|
||||
finally
|
||||
{
|
||||
FastList.recycle(augmentation);
|
||||
}
|
||||
|
||||
// finally, give the tax to the castle...
|
||||
if ((npc != null) && (entry.getTaxAmount() > 0))
|
||||
{
|
||||
npc.getCastle().addToTreasury(entry.getTaxAmount() * _amount);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__B0_MULTISELLCHOOSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.CharTemplateTable;
|
||||
import com.l2jserver.gameserver.model.base.ClassId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NewCharacterSuccess;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class NewCharacter extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__13_NEWCHARACTER = "[C] 13 NewCharacter";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine(_C__13_NEWCHARACTER);
|
||||
}
|
||||
|
||||
final NewCharacterSuccess ct = new NewCharacterSuccess();
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.FIGHTER)); // Human Figther
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.MAGE)); // Human Mystic
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.ELVEN_FIGHTER)); // Elven Fighter
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.ELVEN_MAGE)); // Elven Mystic
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.DARK_FIGHTER)); // Dark Fighter
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.DARK_MAGE)); // Dark Mystic
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.ORC_FIGHTER)); // Orc Fighter
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.ORC_MAGE)); // Orc Mystic
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.DWARVEN_FIGHTER)); // Dwarf Fighter
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.MALE_SOLDIER)); // Male Kamael Soldier
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.FEMALE_SOLDIER)); // Female Kamael Soldier
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.ERTHEIA_FIGHTER)); // Ertheia Fighter
|
||||
ct.addChar(CharTemplateTable.getInstance().getTemplate(ClassId.ERTHEIA_WIZARD)); // Ertheia Wizard
|
||||
sendPacket(ct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__13_NEWCHARACTER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.enums.UserInfoType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class NotifyExitBeautyShop extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_E1_NOTIFYEXITBEAUTYSHOP = "[C] D0:E1 NotifyExitBeautyShop";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UserInfo userInfo = new UserInfo(activeChar, false);
|
||||
userInfo.addComponentType(UserInfoType.APPAREANCE);
|
||||
sendPacket(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_E1_NOTIFYEXITBEAUTYSHOP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.7.4.4 $ $Date: 2005/03/27 18:46:19 $
|
||||
*/
|
||||
public final class ObserverReturn extends L2GameClientPacket
|
||||
{
|
||||
private static final String __C__C1_OBSERVERRETURN = "[C] C1 ObserverReturn";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.inObserverMode())
|
||||
{
|
||||
activeChar.leaveObserverMode();
|
||||
// activeChar.teleToLocation(activeChar.getObsX(), activeChar.getObsY(), activeChar.getObsZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return __C__C1_OBSERVERRETURN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.network.serverpackets.KeyPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.5.2.8.2.8 $ $Date: 2005/04/02 10:43:04 $
|
||||
*/
|
||||
public final class ProtocolVersion extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__0E_PROTOCOLVERSION = "[C] 0E ProtocolVersion";
|
||||
private static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
|
||||
private int _version;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_version = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
// this packet is never encrypted
|
||||
if (_version == -2)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("Ping received");
|
||||
}
|
||||
// this is just a ping attempt from the new C2 client
|
||||
getClient().close((L2GameServerPacket) null);
|
||||
}
|
||||
else if (!Config.PROTOCOL_LIST.contains(_version))
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.WARNING, "Wrong protocol");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
_version,
|
||||
getClient()
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
KeyPacket pk = new KeyPacket(getClient().enableCrypt(), 0);
|
||||
getClient().setProtocolOk(false);
|
||||
getClient().close(pk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Client Protocol Revision is ok: " + _version);
|
||||
}
|
||||
|
||||
KeyPacket pk = new KeyPacket(getClient().enableCrypt(), 1);
|
||||
getClient().sendPacket(pk);
|
||||
getClient().setProtocolOk(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__0E_PROTOCOLVERSION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAbilityList extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExCloseAPListWnd;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAbilityWndClose extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ExCloseAPListWnd.STATIC_PACKET);
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowAPListWnd;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestAbilityWndOpen extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ExShowAPListWnd.STATIC_PACKET);
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SkillTreesData;
|
||||
import com.l2jserver.gameserver.model.L2SkillLearn;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAcquireAbilityList extends L2GameClientPacket
|
||||
{
|
||||
private final List<SkillHolder> _skills = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
readD(); // Total size
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
int size = readD();
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
_skills.add(new SkillHolder(readD(), readD()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getAbilityPoints() == 0) || (activeChar.getAbilityPoints() == activeChar.getAbilityPointsUsed()))
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": Player " + activeChar + " is trying to learn ability without ability points!");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
for (SkillHolder holder : _skills)
|
||||
{
|
||||
final L2SkillLearn learn = SkillTreesData.getInstance().getAbilitySkill(holder.getSkillId(), holder.getSkillLvl());
|
||||
if (learn == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": SkillLearn " + holder.getSkillId() + "(" + holder.getSkillLvl() + ") not found!");
|
||||
sendActionFailed();
|
||||
break;
|
||||
}
|
||||
|
||||
final Skill skill = holder.getSkill();
|
||||
if (skill == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": SkillLearn " + holder.getSkillId() + "(" + holder.getSkillLvl() + ") not found!");
|
||||
sendActionFailed();
|
||||
break;
|
||||
}
|
||||
final int points;
|
||||
final int knownLevel = activeChar.getSkillLevel(holder.getSkillId());
|
||||
if (knownLevel == -1) // player didn't knew it at all!
|
||||
{
|
||||
points = holder.getSkillLvl();
|
||||
}
|
||||
else
|
||||
{
|
||||
points = holder.getSkillLvl() - knownLevel;
|
||||
}
|
||||
|
||||
if ((activeChar.getAbilityPoints() - activeChar.getAbilityPointsUsed()) < points)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": Player " + activeChar + " is trying to learn ability without ability points!");
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.addSkill(skill, true);
|
||||
activeChar.setAbilityPointsUsed(activeChar.getAbilityPointsUsed() + points);
|
||||
}
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.datatables.SkillTreesData;
|
||||
import com.l2jserver.gameserver.enums.IllegalActionPunishmentType;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.enums.UserInfoType;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.ClanPrivilege;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2SkillLearn;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2FishermanInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2VillageMasterInstance;
|
||||
import com.l2jserver.gameserver.model.base.AcquireSkillType;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSkillLearn;
|
||||
import com.l2jserver.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.model.quest.QuestState;
|
||||
import com.l2jserver.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillDone;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquirableSkillListByClass;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAlchemySkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShortCutInit;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Request Acquire Skill client packet implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class RequestAcquireSkill extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__7C_REQUESTACQUIRESKILL = "[C] 7C RequestAcquireSkill";
|
||||
private static final String[] QUEST_VAR_NAMES =
|
||||
{
|
||||
"EmergentAbility65-",
|
||||
"EmergentAbility70-",
|
||||
"ClassAbility75-",
|
||||
"ClassAbility80-"
|
||||
};
|
||||
|
||||
private int _id;
|
||||
private int _level;
|
||||
private AcquireSkillType _skillType;
|
||||
private int _subType;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_id = readD();
|
||||
_level = readD();
|
||||
_skillType = AcquireSkillType.getAcquireSkillType(readD());
|
||||
if (_skillType == AcquireSkillType.SUBPLEDGE)
|
||||
{
|
||||
_subType = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_level < 1) || (_level > 1000) || (_id < 1) || (_id > 32000))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Wrong Packet Data in Aquired Skill", Config.DEFAULT_PUNISH);
|
||||
_log.warning("Recived Wrong Packet Data in Aquired Skill - id: " + _id + " level: " + _level + " for " + activeChar);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc trainer = activeChar.getLastFolkNPC();
|
||||
if (!(trainer instanceof L2NpcInstance) && (_skillType != AcquireSkillType.CLASS))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_skillType != AcquireSkillType.CLASS) && !trainer.canInteract(activeChar) && !activeChar.isGM())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(_id, _level);
|
||||
if (skill == null)
|
||||
{
|
||||
_log.warning(RequestAcquireSkill.class.getSimpleName() + ": Player " + activeChar.getName() + " is trying to learn a null skill Id: " + _id + " level: " + _level + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack check. Doesn't apply to all Skill Types
|
||||
final int prevSkillLevel = activeChar.getSkillLevel(_id);
|
||||
if ((prevSkillLevel > 0) && !((_skillType == AcquireSkillType.TRANSFER) || (_skillType == AcquireSkillType.SUBPLEDGE)))
|
||||
{
|
||||
if (prevSkillLevel == _level)
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " is trying to learn a skill that already knows, Id: " + _id + " level: " + _level + "!");
|
||||
return;
|
||||
}
|
||||
else if (prevSkillLevel != (_level - 1))
|
||||
{
|
||||
// The previous level skill has not been learned.
|
||||
activeChar.sendPacket(SystemMessageId.THE_PREVIOUS_LEVEL_SKILL_HAS_NOT_BEEN_LEARNED);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final L2SkillLearn s = SkillTreesData.getInstance().getSkillLearn(_skillType, _id, _level, activeChar);
|
||||
if (s == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_skillType)
|
||||
{
|
||||
case CLASS:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TRANSFORM:
|
||||
{
|
||||
// Hack check.
|
||||
if (!canTransform(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_NOT_COMPLETED_THE_NECESSARY_QUEST_FOR_SKILL_ACQUISITION);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without required quests!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FISHING:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
int repCost = s.getLevelUpSp();
|
||||
if (clan.getReputationScore() >= repCost)
|
||||
{
|
||||
if (Config.LIFE_CRYSTAL_NEEDED)
|
||||
{
|
||||
for (ItemHolder item : s.getRequiredItems())
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("Consume", item.getId(), item.getCount(), trainer, false))
|
||||
{
|
||||
// Doesn't have required item.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
L2VillageMasterInstance.showPledgeSkillList(activeChar);
|
||||
return;
|
||||
}
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_S_DISAPPEARED);
|
||||
sm.addItemName(item.getId());
|
||||
sm.addLong(item.getCount());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
clan.takeReputationScore(repCost, true);
|
||||
|
||||
final SystemMessage cr = SystemMessage.getSystemMessage(SystemMessageId.S1_POINT_S_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION);
|
||||
cr.addInt(repCost);
|
||||
activeChar.sendPacket(cr);
|
||||
|
||||
clan.addNewSkill(skill);
|
||||
|
||||
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
|
||||
|
||||
activeChar.sendPacket(new AcquireSkillDone());
|
||||
|
||||
L2VillageMasterInstance.showPledgeSkillList(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_ATTEMPT_TO_ACQUIRE_THE_SKILL_HAS_FAILED_BECAUSE_OF_AN_INSUFFICIENT_CLAN_REPUTATION);
|
||||
L2VillageMasterInstance.showPledgeSkillList(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SUBPLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader() || !activeChar.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Clan clan = activeChar.getClan();
|
||||
if ((clan.getFortId() == 0) && (clan.getCastleId() == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack check. Check if SubPledge can accept the new skill:
|
||||
if (!clan.isLearnableSubPledgeSkill(skill, _subType))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SQUAD_SKILL_HAS_ALREADY_BEEN_LEARNED);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
final int repCost = s.getLevelUpSp();
|
||||
if (clan.getReputationScore() < repCost)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_ATTEMPT_TO_ACQUIRE_THE_SKILL_HAS_FAILED_BECAUSE_OF_AN_INSUFFICIENT_CLAN_REPUTATION);
|
||||
return;
|
||||
}
|
||||
|
||||
for (ItemHolder item : s.getRequiredItems())
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("SubSkills", item.getId(), item.getCount(), trainer, false))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
return;
|
||||
}
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_S_DISAPPEARED);
|
||||
sm.addItemName(item.getId());
|
||||
sm.addLong(item.getCount());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (repCost > 0)
|
||||
{
|
||||
clan.takeReputationScore(repCost, true);
|
||||
final SystemMessage cr = SystemMessage.getSystemMessage(SystemMessageId.S1_POINT_S_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION);
|
||||
cr.addInt(repCost);
|
||||
activeChar.sendPacket(cr);
|
||||
}
|
||||
|
||||
clan.addNewSkill(skill, _subType);
|
||||
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
|
||||
activeChar.sendPacket(new AcquireSkillDone());
|
||||
|
||||
showSubUnitSkillList(activeChar);
|
||||
break;
|
||||
}
|
||||
case TRANSFER:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SUBCLASS:
|
||||
{
|
||||
// Hack check.
|
||||
if (activeChar.isSubClassActive())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_SKILL_CANNOT_BE_LEARNED_WHILE_IN_THE_SUBCLASS_STATE_PLEASE_TRY_AGAIN_AFTER_CHANGING_TO_THE_MAIN_CLASS);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " while Sub-Class is active!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Certification Skills - Exploit fix
|
||||
if ((prevSkillLevel == -1) && (_level > 1))
|
||||
{
|
||||
// The previous level skill has not been learned.
|
||||
activeChar.sendPacket(SystemMessageId.THE_PREVIOUS_LEVEL_SKILL_HAS_NOT_BEEN_LEARNED);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " is requesting skill Id: " + _id + " level " + _level + " without knowing it's previous level!", IllegalActionPunishmentType.NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
QuestState st = activeChar.getQuestState("SubClassSkills");
|
||||
if (st == null)
|
||||
{
|
||||
final Quest subClassSkilllsQuest = QuestManager.getInstance().getQuest("SubClassSkills");
|
||||
if (subClassSkilllsQuest != null)
|
||||
{
|
||||
st = subClassSkilllsQuest.newQuestState(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Null SubClassSkills quest, for Sub-Class skill Id: " + _id + " level: " + _level + " for player " + activeChar.getName() + "!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (String varName : QUEST_VAR_NAMES)
|
||||
{
|
||||
for (int i = 1; i <= Config.MAX_SUBCLASS; i++)
|
||||
{
|
||||
final String itemOID = st.getGlobalQuestVar(varName + i);
|
||||
if (!itemOID.isEmpty() && !itemOID.endsWith(";") && !itemOID.equals("0"))
|
||||
{
|
||||
if (Util.isDigit(itemOID))
|
||||
{
|
||||
final int itemObjId = Integer.parseInt(itemOID);
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(itemObjId);
|
||||
if (item != null)
|
||||
{
|
||||
for (ItemHolder itemIdCount : s.getRequiredItems())
|
||||
{
|
||||
if (item.getId() == itemIdCount.getId())
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
// Logging the given skill.
|
||||
st.saveGlobalQuestVar(varName + i, skill.getId() + ";");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Inexistent item for object Id " + itemObjId + ", for Sub-Class skill Id: " + _id + " level: " + _level + " for player " + activeChar.getName() + "!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Invalid item object Id " + itemOID + ", for Sub-Class skill Id: " + _id + " level: " + _level + " for player " + activeChar.getName() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player doesn't have required item.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
showSkillList(trainer, activeChar);
|
||||
break;
|
||||
}
|
||||
case COLLECT:
|
||||
{
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ALCHEMY:
|
||||
{
|
||||
if (activeChar.getRace() != Race.ERTHEIA)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkPlayerSkill(activeChar, trainer, s))
|
||||
{
|
||||
giveSkill(activeChar, trainer, skill);
|
||||
|
||||
activeChar.sendPacket(new AcquireSkillDone());
|
||||
activeChar.sendPacket(new ExAlchemySkillList(activeChar));
|
||||
|
||||
final List<L2SkillLearn> alchemySkills = SkillTreesData.getInstance().getAvailableAlchemySkills(activeChar);
|
||||
|
||||
if (alchemySkills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(alchemySkills, AcquireSkillType.ALCHEMY));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_log.warning("Recived Wrong Packet Data in Aquired Skill, unknown skill type:" + _skillType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void showSubUnitSkillList(L2PcInstance activeChar)
|
||||
{
|
||||
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSubPledgeSkills(activeChar.getClan());
|
||||
|
||||
if (skills.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExAcquirableSkillListByClass(skills, AcquireSkillType.SUBPLEDGE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a simple check for current player and skill.<br>
|
||||
* Takes the needed SP if the skill require it and all requirements are meet.<br>
|
||||
* Consume required items if the skill require it and all requirements are meet.<br>
|
||||
* @param player the skill learning player.
|
||||
* @param trainer the skills teaching Npc.
|
||||
* @param s the skill to be learn.
|
||||
* @return {@code true} if all requirements are meet, {@code false} otherwise.
|
||||
*/
|
||||
private boolean checkPlayerSkill(L2PcInstance player, L2Npc trainer, L2SkillLearn s)
|
||||
{
|
||||
if (s != null)
|
||||
{
|
||||
if ((s.getSkillId() == _id) && (s.getSkillLevel() == _level))
|
||||
{
|
||||
// Hack check.
|
||||
if (s.getGetLevel() > player.getLevel())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_MEET_THE_SKILL_LEVEL_REQUIREMENTS);
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + ", level " + player.getLevel() + " is requesting skill Id: " + _id + " level " + _level + " without having minimum required level, " + s.getGetLevel() + "!", IllegalActionPunishmentType.NONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
// First it checks that the skill require SP and the player has enough SP to learn it.
|
||||
final int levelUpSp = s.getCalculatedLevelUpSp(player.getClassId(), player.getLearningClass());
|
||||
if ((levelUpSp > 0) && (levelUpSp > player.getSp()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SP_TO_LEARN_THIS_SKILL);
|
||||
showSkillList(trainer, player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.DIVINE_SP_BOOK_NEEDED && (_id == CommonSkill.DIVINE_INSPIRATION.getId()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for required skills.
|
||||
if (!s.getPreReqSkills().isEmpty())
|
||||
{
|
||||
for (SkillHolder skill : s.getPreReqSkills())
|
||||
{
|
||||
if (player.getSkillLevel(skill.getSkillId()) != skill.getSkillLvl())
|
||||
{
|
||||
if (skill.getSkillId() == CommonSkill.ONYX_BEAST_TRANSFORMATION.getId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_MUST_LEARN_THE_ONYX_BEAST_SKILL_BEFORE_YOU_CAN_LEARN_FURTHER_SKILLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for required items.
|
||||
if (!s.getRequiredItems().isEmpty())
|
||||
{
|
||||
// Then checks that the player has all the items
|
||||
long reqItemCount = 0;
|
||||
for (ItemHolder item : s.getRequiredItems())
|
||||
{
|
||||
reqItemCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
|
||||
if (reqItemCount < item.getCount())
|
||||
{
|
||||
// Player doesn't have required item.
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
|
||||
showSkillList(trainer, player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If the player has all required items, they are consumed.
|
||||
for (ItemHolder itemIdCount : s.getRequiredItems())
|
||||
{
|
||||
if (!player.destroyItemByItemId("SkillLearn", itemIdCount.getId(), itemIdCount.getCount(), trainer, true))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Somehow player " + player.getName() + ", level " + player.getLevel() + " lose required item Id: " + itemIdCount.getId() + " to learn skill while learning skill Id: " + _id + " level " + _level + "!", IllegalActionPunishmentType.NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the player has SP and all required items then consume SP.
|
||||
if (levelUpSp > 0)
|
||||
{
|
||||
player.setSp(player.getSp() - levelUpSp);
|
||||
UserInfo ui = new UserInfo(player);
|
||||
ui.addComponentType(UserInfoType.CURRENT_HPMPCP_EXP_SP);
|
||||
player.sendPacket(ui);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the skill to the player and makes proper updates.
|
||||
* @param player the player acquiring a skill.
|
||||
* @param trainer the Npc teaching a skill.
|
||||
* @param skill the skill to be learn.
|
||||
*/
|
||||
private void giveSkill(L2PcInstance player, L2Npc trainer, Skill skill)
|
||||
{
|
||||
// Send message.
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S12);
|
||||
sm.addSkillName(skill);
|
||||
player.sendPacket(sm);
|
||||
|
||||
player.addSkill(skill, true);
|
||||
|
||||
player.sendPacket(new ItemList(player, false));
|
||||
player.sendPacket(new ShortCutInit(player));
|
||||
player.sendPacket(new ExBasicActionList(ExBasicActionList.DEFAULT_ACTION_LIST));
|
||||
player.sendSkillList();
|
||||
|
||||
player.updateShortCuts(_id, _level);
|
||||
showSkillList(trainer, player);
|
||||
|
||||
// If skill is expand type then sends packet:
|
||||
if ((_id >= 1368) && (_id <= 1372))
|
||||
{
|
||||
player.sendPacket(new ExStorageMaxCount(player));
|
||||
}
|
||||
|
||||
// Notify scripts of the skill learn.
|
||||
if (trainer != null)
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), trainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for returning the skill list to the player after it's done with current skill.
|
||||
* @param trainer the Npc which the {@code player} is interacting
|
||||
* @param player the active character
|
||||
*/
|
||||
private void showSkillList(L2Npc trainer, L2PcInstance player)
|
||||
{
|
||||
if ((_skillType == AcquireSkillType.TRANSFORM) || (_skillType == AcquireSkillType.SUBCLASS) || (_skillType == AcquireSkillType.TRANSFER))
|
||||
{
|
||||
// Managed in Datapack.
|
||||
return;
|
||||
}
|
||||
|
||||
if (trainer instanceof L2FishermanInstance)
|
||||
{
|
||||
L2FishermanInstance.showFishSkillList(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new AcquireSkillList(player));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the player can transform.
|
||||
* @param player the player to verify
|
||||
* @return {@code true} if the player meets the required conditions to learn a transformation, {@code false} otherwise
|
||||
*/
|
||||
public static boolean canTransform(L2PcInstance player)
|
||||
{
|
||||
if (Config.ALLOW_TRANSFORM_WITHOUT_QUEST)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final QuestState st = player.getQuestState("Q00136_MoreThanMeetsTheEye");
|
||||
return (st != null) && st.isCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__7C_REQUESTACQUIRESKILL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.datatables.SkillTreesData;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.model.ClanPrivilege;
|
||||
import com.l2jserver.gameserver.model.L2SkillLearn;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.base.AcquireSkillType;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireSkillInfo;
|
||||
|
||||
/**
|
||||
* Request Acquire Skill Info client packet implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class RequestAcquireSkillInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__73_REQUESTACQUIRESKILLINFO = "[C] 73 RequestAcquireSkillInfo";
|
||||
|
||||
private int _id;
|
||||
private int _level;
|
||||
private AcquireSkillType _skillType;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_id = readD();
|
||||
_level = readD();
|
||||
_skillType = AcquireSkillType.getAcquireSkillType(readD());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if ((_id <= 0) || (_level <= 0))
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Invalid Id: " + _id + " or level: " + _level + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc trainer = activeChar.getLastFolkNPC();
|
||||
if (!(trainer instanceof L2NpcInstance) && (_skillType != AcquireSkillType.CLASS))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_skillType != AcquireSkillType.CLASS) && !trainer.canInteract(activeChar) && !activeChar.isGM())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(_id, _level);
|
||||
if (skill == null)
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Skill Id: " + _id + " level: " + _level + " is undefined. " + RequestAcquireSkillInfo.class.getName() + " failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Hack check. Doesn't apply to all Skill Types
|
||||
final int prevSkillLevel = activeChar.getSkillLevel(_id);
|
||||
if ((prevSkillLevel > 0) && !((_skillType == AcquireSkillType.TRANSFER) || (_skillType == AcquireSkillType.SUBPLEDGE)))
|
||||
{
|
||||
if (prevSkillLevel == _level)
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Player " + activeChar.getName() + " is trequesting info for a skill that already knows, Id: " + _id + " level: " + _level + "!");
|
||||
}
|
||||
else if (prevSkillLevel != (_level - 1))
|
||||
{
|
||||
_log.warning(RequestAcquireSkillInfo.class.getSimpleName() + ": Player " + activeChar.getName() + " is requesting info for skill Id: " + _id + " level " + _level + " without knowing it's previous level!");
|
||||
}
|
||||
}
|
||||
|
||||
final L2SkillLearn s = SkillTreesData.getInstance().getSkillLearn(_skillType, _id, _level, activeChar);
|
||||
if (s == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_skillType)
|
||||
{
|
||||
case TRANSFORM:
|
||||
case FISHING:
|
||||
case SUBCLASS:
|
||||
case COLLECT:
|
||||
case TRANSFER:
|
||||
{
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case CLASS:
|
||||
{
|
||||
final int customSp = s.getCalculatedLevelUpSp(activeChar.getClassId(), activeChar.getLearningClass());
|
||||
sendPacket(new ExAcquireSkillInfo(activeChar, s, customSp));
|
||||
break;
|
||||
}
|
||||
case PLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader())
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case SUBPLEDGE:
|
||||
{
|
||||
if (!activeChar.isClanLeader() || !activeChar.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
case ALCHEMY:
|
||||
{
|
||||
if (activeChar.getRace() != Race.ERTHEIA)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendPacket(new AcquireSkillInfo(_skillType, s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__73_REQUESTACQUIRESKILLINFO;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAlchemySkillList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestAlchemySkillList extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if ((activeChar == null) || (activeChar.getRace() != Race.ERTHEIA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
activeChar.sendPacket(new ExAlchemySkillList(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowAgitInfo;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestAllAgitInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_3E_REQUESTALLAGITINFO = "[C] D0:3E RequestAllAgitInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2GameClient client = getClient();
|
||||
if (client != null)
|
||||
{
|
||||
client.sendPacket(new ExShowAgitInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_3E_REQUESTALLAGITINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowCastleInfo;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestAllCastleInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_3C_REQUESTALLCASTLEINFO = "[C] D0:3C RequestAllCastleInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2GameClient client = getClient();
|
||||
if (client != null)
|
||||
{
|
||||
client.sendPacket(new ExShowCastleInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_3C_REQUESTALLCASTLEINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.network.L2GameClient;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowFortressInfo;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestAllFortressInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_3D_REQUESTALLFORTRESSINFO = "[C] D0:3D RequestAllFortressInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger packet
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2GameClient client = getClient();
|
||||
if (client != null)
|
||||
{
|
||||
client.sendPacket(ExShowFortressInfo.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_3D_REQUESTALLFORTRESSINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.network.serverpackets.AllyCrest;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.4.4 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestAllyCrest extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__92_REQUESTALLYCREST = "[C] 92 RequestAllyCrest";
|
||||
|
||||
private int _crestId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_crestId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
sendPacket(new AllyCrest(_crestId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__92_REQUESTALLYCREST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.ClanInfo;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AllianceInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1479 $ $Date: 2005-11-09 00:47:42 +0100 (mer., 09 nov. 2005) $
|
||||
*/
|
||||
public final class RequestAllyInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__2E_REQUESTALLYINFO = "[C] 2E RequestAllyInfo";
|
||||
|
||||
@Override
|
||||
public void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
final int allianceId = activeChar.getAllyId();
|
||||
if (allianceId > 0)
|
||||
{
|
||||
final AllianceInfo ai = new AllianceInfo(allianceId);
|
||||
activeChar.sendPacket(ai);
|
||||
|
||||
// send for player
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_INFORMATION);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_NAME_S1);
|
||||
sm.addString(ai.getName());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_LEADER_S2_OF_S1);
|
||||
sm.addString(ai.getLeaderC());
|
||||
sm.addString(ai.getLeaderP());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
|
||||
sm.addInt(ai.getOnline());
|
||||
sm.addInt(ai.getTotal());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.AFFILIATED_CLANS_TOTAL_S1_CLAN_S);
|
||||
sm.addInt(ai.getAllies().length);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFORMATION);
|
||||
for (final ClanInfo aci : ai.getAllies())
|
||||
{
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_NAME_S1);
|
||||
sm.addString(aci.getClan().getName());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEADER_S1);
|
||||
sm.addString(aci.getClan().getLeaderName());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEVEL_S1);
|
||||
sm.addInt(aci.getClan().getLevel());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
|
||||
sm.addInt(aci.getOnline());
|
||||
sm.addInt(aci.getTotal());
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.EMPTY4);
|
||||
}
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.EMPTY5);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_CURRENTLY_ALLIED_WITH_ANY_CLANS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__2E_REQUESTALLYINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class RequestAnswerJoinAlly extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__8D_REQUESTANSWERJOINALLY = "[C] 8D RequestAnswerJoinAlly";
|
||||
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance requestor = activeChar.getRequest().getPartner();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_response == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.NO_RESPONSE_YOUR_ENTRANCE_TO_THE_ALLIANCE_HAS_BEEN_CANCELLED);
|
||||
requestor.sendPacket(SystemMessageId.NO_RESPONSE_INVITATION_TO_JOIN_AN_ALLIANCE_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinAlly))
|
||||
{
|
||||
return; // hax
|
||||
}
|
||||
|
||||
L2Clan clan = requestor.getClan();
|
||||
// we must double check this cause of hack
|
||||
if (clan.checkAllyJoinCondition(requestor, activeChar))
|
||||
{
|
||||
// TODO: Need correct message id
|
||||
requestor.sendPacket(SystemMessageId.THAT_PERSON_HAS_BEEN_SUCCESSFULLY_ADDED_TO_YOUR_FRIEND_LIST);
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_ACCEPTED_THE_ALLIANCE);
|
||||
|
||||
activeChar.getClan().setAllyId(clan.getAllyId());
|
||||
activeChar.getClan().setAllyName(clan.getAllyName());
|
||||
activeChar.getClan().setAllyPenaltyExpiryTime(0, 0);
|
||||
activeChar.getClan().changeAllyCrest(clan.getAllyCrestId(), true);
|
||||
activeChar.getClan().updateClanInDB();
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.getRequest().onRequestResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__8D_REQUESTANSWERJOINALLY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Party.messageType;
|
||||
import com.l2jserver.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jserver.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExManagePartyRoomMember;
|
||||
import com.l2jserver.gameserver.network.serverpackets.JoinParty;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public final class RequestAnswerJoinParty extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__43_REQUESTANSWERPARTY = "[C] 43 RequestAnswerJoinParty";
|
||||
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance requestor = player.getActiveRequester();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
requestor.sendPacket(new JoinParty(_response));
|
||||
|
||||
if (_response == 1)
|
||||
{
|
||||
if (requestor.isInParty())
|
||||
{
|
||||
if (requestor.getParty().getMemberCount() >= 9)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_PARTY_IS_FULL);
|
||||
player.sendPacket(sm);
|
||||
requestor.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.joinParty(requestor.getParty());
|
||||
|
||||
if (requestor.isInPartyMatchRoom() && player.isInPartyMatchRoom())
|
||||
{
|
||||
final PartyMatchRoomList list = PartyMatchRoomList.getInstance();
|
||||
if ((list != null) && (list.getPlayerRoomId(requestor) == list.getPlayerRoomId(player)))
|
||||
{
|
||||
final PartyMatchRoom room = list.getPlayerRoom(requestor);
|
||||
if (room != null)
|
||||
{
|
||||
final ExManagePartyRoomMember packet = new ExManagePartyRoomMember(player, room, 1);
|
||||
for (L2PcInstance member : room.getPartyMembers())
|
||||
{
|
||||
if (member != null)
|
||||
{
|
||||
member.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (requestor.isInPartyMatchRoom() && !player.isInPartyMatchRoom())
|
||||
{
|
||||
final PartyMatchRoomList list = PartyMatchRoomList.getInstance();
|
||||
if (list != null)
|
||||
{
|
||||
final PartyMatchRoom room = list.getPlayerRoom(requestor);
|
||||
if (room != null)
|
||||
{
|
||||
room.addMember(player);
|
||||
ExManagePartyRoomMember packet = new ExManagePartyRoomMember(player, room, 1);
|
||||
for (L2PcInstance member : room.getPartyMembers())
|
||||
{
|
||||
if (member != null)
|
||||
{
|
||||
member.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
player.setPartyRoom(room.getId());
|
||||
// player.setPartyMatching(1);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_response == -1)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_PARTY_REQUESTS_AND_CANNOT_RECEIVE_A_PARTY_REQUEST);
|
||||
sm.addPcName(player);
|
||||
requestor.sendPacket(sm);
|
||||
|
||||
// activate garbage collection if there are no other members in party (happens when we were creating new one)
|
||||
if (requestor.isInParty() && (requestor.getParty().getMemberCount() == 1))
|
||||
{
|
||||
requestor.getParty().removePartyMember(requestor, messageType.None);
|
||||
}
|
||||
}
|
||||
else
|
||||
// 0
|
||||
{
|
||||
// requestor.sendPacket(SystemMessageId.THE_PLAYER_DECLINED_TO_JOIN_YOUR_PARTY); FIXME: Done in client?
|
||||
|
||||
// activate garbage collection if there are no other members in party (happens when we were creating new one)
|
||||
if (requestor.isInParty() && (requestor.getParty().getMemberCount() == 1))
|
||||
{
|
||||
requestor.getParty().removePartyMember(requestor, messageType.None);
|
||||
}
|
||||
}
|
||||
|
||||
if (requestor.isInParty())
|
||||
{
|
||||
requestor.getParty().setPendingInvitation(false); // if party is null, there is no need of decreasing
|
||||
}
|
||||
|
||||
player.setActiveRequester(null);
|
||||
requestor.onTransactionResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__43_REQUESTANSWERPARTY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.FortManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.JoinPledge;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeShowInfoUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAdd;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.4.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestAnswerJoinPledge extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__27_REQUESTANSWERJOINPLEDGE = "[C] 27 RequestAnswerJoinPledge";
|
||||
|
||||
private int _answer;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_answer = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance requestor = activeChar.getRequest().getPartner();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_answer == 0)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DIDN_T_RESPOND_TO_S1_S_INVITATION_JOINING_HAS_BEEN_CANCELLED);
|
||||
sm.addString(requestor.getName());
|
||||
activeChar.sendPacket(sm);
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DID_NOT_RESPOND_INVITATION_TO_THE_CLAN_HAS_BEEN_CANCELLED);
|
||||
sm.addString(activeChar.getName());
|
||||
requestor.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinPledge))
|
||||
{
|
||||
return; // hax
|
||||
}
|
||||
|
||||
RequestJoinPledge requestPacket = (RequestJoinPledge) requestor.getRequest().getRequestPacket();
|
||||
L2Clan clan = requestor.getClan();
|
||||
// we must double check this cause during response time conditions can be changed, i.e. another player could join clan
|
||||
if (clan.checkClanJoinCondition(requestor, activeChar, requestPacket.getPledgeType()))
|
||||
{
|
||||
activeChar.sendPacket(new JoinPledge(requestor.getClanId()));
|
||||
|
||||
activeChar.setPledgeType(requestPacket.getPledgeType());
|
||||
if (requestPacket.getPledgeType() == L2Clan.SUBUNIT_ACADEMY)
|
||||
{
|
||||
activeChar.setPowerGrade(9); // adademy
|
||||
activeChar.setLvlJoinedAcademy(activeChar.getLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setPowerGrade(5); // new member starts at 5, not confirmed
|
||||
}
|
||||
|
||||
clan.addClanMember(activeChar);
|
||||
activeChar.setClanPrivileges(activeChar.getClan().getRankPrivs(activeChar.getPowerGrade()));
|
||||
activeChar.sendPacket(SystemMessageId.ENTERED_THE_CLAN);
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_JOINED_THE_CLAN);
|
||||
sm.addString(activeChar.getName());
|
||||
clan.broadcastToOnlineMembers(sm);
|
||||
|
||||
if (activeChar.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
|
||||
}
|
||||
if (activeChar.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
|
||||
}
|
||||
activeChar.sendSkillList();
|
||||
|
||||
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListAdd(activeChar), activeChar);
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
|
||||
// this activates the clan tab on the new member
|
||||
activeChar.sendPacket(new PledgeShowMemberListAll(clan));
|
||||
activeChar.setClanJoinExpiryTime(0);
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.getRequest().onRequestResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__27_REQUESTANSWERJOINPLEDGE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAskJoinPartyRoom;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format: (ch) S
|
||||
* @author -Wooden-, Tryskell
|
||||
*/
|
||||
public class RequestAskJoinPartyRoom extends L2GameClientPacket
|
||||
{
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Send PartyRoom invite request (with activeChar) name to the target
|
||||
final L2PcInstance target = L2World.getInstance().getPlayer(_name);
|
||||
if (target != null)
|
||||
{
|
||||
if (!target.isProcessingRequest())
|
||||
{
|
||||
player.onTransactionRequest(target);
|
||||
target.sendPacket(new ExAskJoinPartyRoom(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER).addPcName(target));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "[C] D0:14 RequestAskJoinPartyRoom";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.0.0.0 $ $Date: 2005/07/11 15:29:30 $
|
||||
*/
|
||||
public final class RequestAutoSoulShot extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_0D_REQUESTAUTOSOULSHOT = "[C] D0:0D RequestAutoSoulShot";
|
||||
|
||||
// format cd
|
||||
private int _itemId;
|
||||
private int _type; // 1 = on : 0 = off;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_itemId = readD();
|
||||
_type = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getPrivateStoreType() == PrivateStoreType.NONE) && (activeChar.getActiveRequester() == null) && !activeChar.isDead())
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("AutoSoulShot:" + _itemId);
|
||||
}
|
||||
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByItemId(_itemId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_type == 1)
|
||||
{
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(item.getId()))
|
||||
{
|
||||
activeChar.sendMessage("Cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fishingshots are not automatic on retail
|
||||
if ((_itemId < 6535) || (_itemId > 6540))
|
||||
{
|
||||
// Attempt to charge first shot on activation
|
||||
if ((_itemId == 6645) || (_itemId == 6646) || (_itemId == 6647) || (_itemId == 20332) || (_itemId == 20333) || (_itemId == 20334))
|
||||
{
|
||||
if (activeChar.hasSummon())
|
||||
{
|
||||
if (item.getEtcItem().getHandlerName().equals("BeastSoulShot"))
|
||||
{
|
||||
if (activeChar.getSummon().getSoulShotsPerHit() > item.getCount())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activeChar.getSummon().getSpiritShotsPerHit() > item.getCount())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_SOULSHOTS_NEEDED_FOR_A_PET_SERVITOR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
activeChar.addAutoSoulShot(_itemId);
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
|
||||
|
||||
// start the auto soulshot use
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_ACTIVATED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
activeChar.rechargeShots(true, true);
|
||||
activeChar.getSummon().rechargeShots(true, true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_SERVITOR_OR_PET_AND_THEREFORE_CANNOT_USE_THE_AUTOMATIC_USE_FUNCTION);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((activeChar.getActiveWeaponItem() != activeChar.getFistsWeaponItem()) && (item.getItem().getCrystalType() == activeChar.getActiveWeaponItem().getItemGradeSPlus()))
|
||||
{
|
||||
activeChar.addAutoSoulShot(_itemId);
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((_itemId >= 2509) && (_itemId <= 2514)) || ((_itemId >= 3947) && (_itemId <= 3952)) || (_itemId == 5790) || ((_itemId >= 22072) && (_itemId <= 22081)))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_DOES_NOT_MATCH_THE_WEAPON_S_GRADE);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_SOULSHOT_YOU_ARE_ATTEMPTING_TO_USE_DOES_NOT_MATCH_THE_GRADE_OF_YOUR_EQUIPPED_WEAPON);
|
||||
}
|
||||
|
||||
activeChar.addAutoSoulShot(_itemId);
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
|
||||
}
|
||||
|
||||
// start the auto soulshot use
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_ACTIVATED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
activeChar.rechargeShots(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_type == 0)
|
||||
{
|
||||
activeChar.removeAutoSoulShot(_itemId);
|
||||
activeChar.sendPacket(new ExAutoSoulShot(_itemId, _type));
|
||||
|
||||
// cancel the auto soulshot use
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_DEACTIVATED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_0D_REQUESTAUTOSOULSHOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
|
||||
|
||||
/**
|
||||
* RequestBBSwrite client packet implementation.
|
||||
* @author -Wooden-, Zoey76
|
||||
*/
|
||||
public final class RequestBBSwrite extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__24_REQUESTBBSWRITE = "[C] 24 RequestBBSwrite";
|
||||
private String _url;
|
||||
private String _arg1;
|
||||
private String _arg2;
|
||||
private String _arg3;
|
||||
private String _arg4;
|
||||
private String _arg5;
|
||||
|
||||
@Override
|
||||
protected final void readImpl()
|
||||
{
|
||||
_url = readS();
|
||||
_arg1 = readS();
|
||||
_arg2 = readS();
|
||||
_arg3 = readS();
|
||||
_arg4 = readS();
|
||||
_arg5 = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void runImpl()
|
||||
{
|
||||
CommunityBoardHandler.getInstance().handleWriteCommand(getActiveChar(), _url, _arg1, _arg2, _arg3, _arg4, _arg5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getType()
|
||||
{
|
||||
return _C__24_REQUESTBBSWRITE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.itemauction.ItemAuction;
|
||||
import com.l2jserver.gameserver.model.itemauction.ItemAuctionInstance;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
*/
|
||||
public final class RequestBidItemAuction extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_39_REQUESTBIDITEMAUCTION = "[C] D0:39 RequestBidItemAuction";
|
||||
|
||||
private int _instanceId;
|
||||
private long _bid;
|
||||
|
||||
@Override
|
||||
protected final void readImpl()
|
||||
{
|
||||
_instanceId = super.readD();
|
||||
_bid = super.readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = super.getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// can't use auction fp here
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("auction"))
|
||||
{
|
||||
activeChar.sendMessage("You are bidding too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_bid < 0) || (_bid > Inventory.MAX_ADENA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemAuctionInstance instance = ItemAuctionManager.getInstance().getManagerInstance(_instanceId);
|
||||
if (instance != null)
|
||||
{
|
||||
final ItemAuction auction = instance.getCurrentAuction();
|
||||
if (auction != null)
|
||||
{
|
||||
auction.registerBid(activeChar, _bid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getType()
|
||||
{
|
||||
return _C__D0_39_REQUESTBIDITEMAUCTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.model.BlockList;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
public final class RequestBlock extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__A9_REQUESTBLOCK = "[C] A9 RequestBlock";
|
||||
|
||||
private static final int BLOCK = 0;
|
||||
private static final int UNBLOCK = 1;
|
||||
private static final int BLOCKLIST = 2;
|
||||
private static final int ALLBLOCK = 3;
|
||||
private static final int ALLUNBLOCK = 4;
|
||||
|
||||
private String _name;
|
||||
private Integer _type;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_type = readD(); // 0x00 - block, 0x01 - unblock, 0x03 - allblock, 0x04 - allunblock
|
||||
|
||||
if ((_type == BLOCK) || (_type == UNBLOCK))
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
final int targetId = CharNameTable.getInstance().getIdByName(_name);
|
||||
final int targetAL = CharNameTable.getInstance().getAccessLevelById(targetId);
|
||||
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case BLOCK:
|
||||
case UNBLOCK:
|
||||
// can't use block/unblock for locating invisible characters
|
||||
if (targetId <= 0)
|
||||
{
|
||||
// Incorrect player name.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_FAILED_TO_REGISTER_THE_USER_TO_YOUR_IGNORE_LIST);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetAL > 0)
|
||||
{
|
||||
// Cannot block a GM character.
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_IMPOSE_A_BLOCK_ON_A_GM);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getObjectId() == targetId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_type == BLOCK)
|
||||
{
|
||||
BlockList.addToBlockList(activeChar, targetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockList.removeFromBlockList(activeChar, targetId);
|
||||
}
|
||||
break;
|
||||
case BLOCKLIST:
|
||||
BlockList.sendListToOwner(activeChar);
|
||||
break;
|
||||
case ALLBLOCK:
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_REFUSAL_MODE);
|
||||
BlockList.setBlockAll(activeChar, true);
|
||||
break;
|
||||
case ALLUNBLOCK:
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_ACCEPTANCE_MODE);
|
||||
BlockList.setBlockAll(activeChar, false);
|
||||
break;
|
||||
default:
|
||||
_log.info("Unknown 0xA9 block type: " + _type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__A9_REQUESTBLOCK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
|
||||
|
||||
/**
|
||||
* @author ShanSoft Packets Structure: chddd
|
||||
*/
|
||||
public final class RequestBookMarkSlotInfo extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_51_00_REQUESTBOOKMARKSLOTINFO = "[C] D0:51:00 RequestBookMarkSlotInfo";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// There is nothing to read.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
player.sendPacket(new ExGetBookMarkInfoPacket(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_51_00_REQUESTBOOKMARKSLOTINFO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import static com.l2jserver.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
|
||||
import static com.l2jserver.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.BuyListData;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.buylist.L2BuyList;
|
||||
import com.l2jserver.gameserver.model.buylist.Product;
|
||||
import com.l2jserver.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBuySellList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
public final class RequestBuyItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__40_REQUESTBUYITEM = "[C] 40 RequestBuyItem";
|
||||
|
||||
private static final int BATCH_LENGTH = 12;
|
||||
private int _listId;
|
||||
private List<ItemHolder> _items = null;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_listId = readD();
|
||||
int size = readD();
|
||||
if ((size <= 0) || (size > Config.MAX_ITEM_IN_PACKET) || ((size * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_items = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
int itemId = readD();
|
||||
long count = readQ();
|
||||
if ((itemId < 1) || (count < 1))
|
||||
{
|
||||
_items = null;
|
||||
return;
|
||||
}
|
||||
_items.add(new ItemHolder(itemId, count));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("buy"))
|
||||
{
|
||||
player.sendMessage("You are buying too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_items == null)
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Alt game - Karma punishment
|
||||
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (player.getKarma() > 0))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
L2Object target = player.getTarget();
|
||||
L2Character merchant = null;
|
||||
if (!player.isGM())
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceId() != target.getInstanceId()))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
merchant = (L2Character) target;
|
||||
}
|
||||
|
||||
double castleTaxRate = 0;
|
||||
double baseTaxRate = 0;
|
||||
|
||||
if ((merchant == null) && !player.isGM())
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2BuyList buyList = BuyListData.getInstance().getBuyList(_listId);
|
||||
if (buyList == null)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId, Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (merchant != null)
|
||||
{
|
||||
if (!buyList.isNpcAllowed(merchant.getId()))
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (merchant instanceof L2MerchantInstance)
|
||||
{
|
||||
castleTaxRate = ((L2MerchantInstance) merchant).getMpc().getCastleTaxRate();
|
||||
baseTaxRate = ((L2MerchantInstance) merchant).getMpc().getBaseTaxRate();
|
||||
}
|
||||
else
|
||||
{
|
||||
baseTaxRate = 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
long subTotal = 0;
|
||||
|
||||
// Check for buylist validity and calculates summary values
|
||||
long slots = 0;
|
||||
long weight = 0;
|
||||
for (ItemHolder i : _items)
|
||||
{
|
||||
long price = -1;
|
||||
|
||||
final Product product = buyList.getProductByItemId(i.getId());
|
||||
if (product == null)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId + " and item_id " + i.getId(), Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!product.getItem().isStackable() && (i.getCount() > 1))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase invalid quantity of items at the same time.", Config.DEFAULT_PUNISH);
|
||||
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED));
|
||||
return;
|
||||
}
|
||||
|
||||
price = product.getPrice();
|
||||
if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026))
|
||||
{
|
||||
price *= Config.RATE_SIEGE_GUARDS_PRICE;
|
||||
}
|
||||
|
||||
if (price < 0)
|
||||
{
|
||||
_log.warning("ERROR, no price found .. wrong buylist ??");
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((price == 0) && !player.isGM() && Config.ONLY_GM_ITEMS_FREE)
|
||||
{
|
||||
player.sendMessage("Ohh Cheat dont work? You have a problem now!");
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried buy item for 0 adena.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (product.hasLimitedStock())
|
||||
{
|
||||
// trying to buy more then available
|
||||
if (i.getCount() > product.getCount())
|
||||
{
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((MAX_ADENA / i.getCount()) < price)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
// first calculate price per item with tax, then multiply by count
|
||||
price = (long) (price * (1 + castleTaxRate + baseTaxRate));
|
||||
subTotal += i.getCount() * price;
|
||||
if (subTotal > MAX_ADENA)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
weight += i.getCount() * product.getItem().getWeight();
|
||||
if (player.getInventory().getItemByItemId(product.getItemId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.isGM() && ((weight > Integer.MAX_VALUE) || (weight < 0) || !player.getInventory().validateWeight((int) weight)))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isGM() && ((slots > Integer.MAX_VALUE) || (slots < 0) || !player.getInventory().validateCapacity((int) slots)))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_INVENTORY_IS_FULL);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Charge buyer and add tax to castle treasury if not owned by npc clan
|
||||
if ((subTotal < 0) || !player.reduceAdena("Buy", subTotal, player.getLastFolkNPC(), false))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
|
||||
sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed the purchase
|
||||
for (ItemHolder i : _items)
|
||||
{
|
||||
Product product = buyList.getProductByItemId(i.getId());
|
||||
if (product == null)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id " + _listId + " and item_id " + i.getId(), Config.DEFAULT_PUNISH);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (product.hasLimitedStock())
|
||||
{
|
||||
if (product.decreaseCount(i.getCount()))
|
||||
{
|
||||
player.getInventory().addItem("Buy", i.getId(), i.getCount(), player, merchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getInventory().addItem("Buy", i.getId(), i.getCount(), player, merchant);
|
||||
}
|
||||
}
|
||||
|
||||
// add to castle treasury
|
||||
if (merchant instanceof L2MerchantInstance)
|
||||
{
|
||||
((L2MerchantInstance) merchant).getCastle().addToTreasury((long) (subTotal * castleTaxRate));
|
||||
}
|
||||
|
||||
player.sendPacket(new ExUserInfoInvenWeight(player));
|
||||
player.sendPacket(new ExBuySellList(player, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__40_REQUESTBUYITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import static com.l2jserver.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jserver.gameserver.model.SeedProduction;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
import com.l2jserver.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author l3x
|
||||
*/
|
||||
public class RequestBuySeed extends L2GameClientPacket
|
||||
{
|
||||
private static final int BATCH_LENGTH = 12; // length of the one item
|
||||
private int _manorId;
|
||||
private List<ItemHolder> _items = null;
|
||||
|
||||
@Override
|
||||
protected final void readImpl()
|
||||
{
|
||||
_manorId = readD();
|
||||
final int count = readD();
|
||||
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_items = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
final int itemId = readD();
|
||||
final long cnt = readQ();
|
||||
if ((cnt < 1) || (itemId < 1))
|
||||
{
|
||||
_items = null;
|
||||
return;
|
||||
}
|
||||
_items.add(new ItemHolder(itemId, cnt));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void runImpl()
|
||||
{
|
||||
final L2PcInstance player = getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!getClient().getFloodProtectors().getManor().tryPerformAction("BuySeed"))
|
||||
{
|
||||
player.sendMessage("You are buying seeds too fast!");
|
||||
return;
|
||||
}
|
||||
else if (_items == null)
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
final CastleManorManager manor = CastleManorManager.getInstance();
|
||||
if (manor.isUnderMaintenance())
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(_manorId);
|
||||
if (castle == null)
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Npc manager = player.getLastFolkNPC();
|
||||
if (!(manager instanceof L2MerchantInstance) || !manager.canInteract(player) || (manager.getTemplate().getParameters().getInt("manor_id", -1) != _manorId))
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
long totalPrice = 0;
|
||||
int slots = 0;
|
||||
int totalWeight = 0;
|
||||
|
||||
final Map<Integer, SeedProduction> _productInfo = new HashMap<>();
|
||||
for (ItemHolder ih : _items)
|
||||
{
|
||||
final SeedProduction sp = manor.getSeedProduct(_manorId, ih.getId(), false);
|
||||
if ((sp == null) || (sp.getPrice() <= 0) || (sp.getAmount() < ih.getCount()) || ((MAX_ADENA / ih.getCount()) < sp.getPrice()))
|
||||
{
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate price
|
||||
totalPrice += (sp.getPrice() * ih.getCount());
|
||||
if (totalPrice > MAX_ADENA)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + MAX_ADENA + " adena worth of goods.", Config.DEFAULT_PUNISH);
|
||||
sendActionFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate weight
|
||||
final L2Item template = ItemTable.getInstance().getTemplate(ih.getId());
|
||||
totalWeight += ih.getCount() * template.getWeight();
|
||||
|
||||
// Calculate slots
|
||||
if (!template.isStackable())
|
||||
{
|
||||
slots += ih.getCount();
|
||||
}
|
||||
else if (player.getInventory().getItemByItemId(ih.getId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
_productInfo.put(ih.getId(), sp);
|
||||
}
|
||||
|
||||
if (!player.getInventory().validateWeight(totalWeight))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
|
||||
return;
|
||||
}
|
||||
else if (!player.getInventory().validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
else if ((totalPrice < 0) || (player.getAdena() < totalPrice))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed the purchase
|
||||
for (ItemHolder i : _items)
|
||||
{
|
||||
final SeedProduction sp = _productInfo.get(i.getId());
|
||||
final long price = sp.getPrice() * i.getCount();
|
||||
|
||||
// Take Adena and decrease seed amount
|
||||
if (!sp.decreaseAmount(i.getCount()) || !player.reduceAdena("Buy", price, player, false))
|
||||
{
|
||||
// failed buy, reduce total price
|
||||
totalPrice -= price;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add item to player's inventory
|
||||
player.addItem("Buy", i.getId(), i.getCount(), manager, true);
|
||||
}
|
||||
|
||||
// Adding to treasury for Manor Castle
|
||||
if (totalPrice > 0)
|
||||
{
|
||||
castle.addToTreasuryNoTax(totalPrice);
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_ADENA_DISAPPEARED);
|
||||
sm.addLong(totalPrice);
|
||||
player.sendPacket(sm);
|
||||
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
manor.updateCurrentProduction(_manorId, _productInfo.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "[C] C5 RequestBuySeed";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
|
||||
public class RequestBuySellUIClose extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_76_REQUESTBUYSELLUICLOSE = "[C] D0:76 RequestBuySellUIClose";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || activeChar.isInventoryDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ItemList(activeChar, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_76_REQUESTBUYSELLUICLOSE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.enums.PlayerAction;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.BypassHandler;
|
||||
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Hero;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcManorBypass;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerBypass;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ConfirmDlg;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* RequestBypassToServer client packet implementation.
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public final class RequestBypassToServer extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__23_REQUESTBYPASSTOSERVER = "[C] 23 RequestBypassToServer";
|
||||
// FIXME: This is for compatibility, will be changed when bypass functionality got an overhaul by NosBit
|
||||
private static final String[] _possibleNonHtmlCommands =
|
||||
{
|
||||
"_bbs",
|
||||
"bbs",
|
||||
"_mail",
|
||||
"_friend",
|
||||
"_match",
|
||||
"_diary",
|
||||
"_olympiad?command",
|
||||
"manor_menu_select"
|
||||
};
|
||||
|
||||
// S
|
||||
private String _command;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_command = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_command.isEmpty())
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent empty bypass!");
|
||||
activeChar.logout();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean requiresBypassValidation = true;
|
||||
for (String possibleNonHtmlCommand : _possibleNonHtmlCommands)
|
||||
{
|
||||
if (_command.startsWith(possibleNonHtmlCommand))
|
||||
{
|
||||
requiresBypassValidation = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int bypassOriginId = 0;
|
||||
if (requiresBypassValidation)
|
||||
{
|
||||
bypassOriginId = activeChar.validateHtmlAction(_command);
|
||||
if (bypassOriginId == -1)
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent non cached bypass: '" + _command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((bypassOriginId > 0) && !Util.isInsideRangeOfObjectId(activeChar, bypassOriginId, L2Npc.INTERACTION_DISTANCE))
|
||||
{
|
||||
// No logging here, this could be a common case where the player has the html still open and run too far away and then clicks a html action
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getServerBypass().tryPerformAction(_command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_command.startsWith("admin_"))
|
||||
{
|
||||
String command = _command.split(" ")[0];
|
||||
|
||||
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
|
||||
if (ach == null)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
activeChar.sendMessage("The command " + command.substring(6) + " does not exist!");
|
||||
}
|
||||
_log.warning(activeChar + " requested not registered admin command '" + command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdminTable.getInstance().hasAccess(command, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access rights to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tried to use admin command " + command + ", without proper access level!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (AdminTable.getInstance().requireConfirm(command))
|
||||
{
|
||||
activeChar.setAdminConfirmCmd(_command);
|
||||
ConfirmDlg dlg = new ConfirmDlg(SystemMessageId.S13);
|
||||
dlg.addString("Are you sure you want execute command " + _command.substring(6) + " ?");
|
||||
activeChar.addAction(PlayerAction.ADMIN_COMMAND);
|
||||
activeChar.sendPacket(dlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", _command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
|
||||
}
|
||||
|
||||
ach.useAdminCommand(_command, activeChar);
|
||||
}
|
||||
}
|
||||
else if (CommunityBoardHandler.getInstance().isCommunityBoardCommand(_command))
|
||||
{
|
||||
CommunityBoardHandler.getInstance().handleParseCommand(_command, activeChar);
|
||||
}
|
||||
else if (_command.equals("come_here") && activeChar.isGM())
|
||||
{
|
||||
comeHere(activeChar);
|
||||
}
|
||||
else if (_command.startsWith("npc_"))
|
||||
{
|
||||
int endOfId = _command.indexOf('_', 5);
|
||||
String id;
|
||||
if (endOfId > 0)
|
||||
{
|
||||
id = _command.substring(4, endOfId);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = _command.substring(4);
|
||||
}
|
||||
if (Util.isDigit(id))
|
||||
{
|
||||
L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
|
||||
|
||||
if ((object != null) && object.isNpc() && (endOfId > 0) && activeChar.isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (_command.startsWith("item_"))
|
||||
{
|
||||
int endOfId = _command.indexOf('_', 5);
|
||||
String id;
|
||||
if (endOfId > 0)
|
||||
{
|
||||
id = _command.substring(5, endOfId);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = _command.substring(5);
|
||||
}
|
||||
try
|
||||
{
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(Integer.parseInt(id));
|
||||
if ((item != null) && (endOfId > 0))
|
||||
{
|
||||
item.onBypassFeedback(activeChar, _command.substring(endOfId + 1));
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
_log.log(Level.WARNING, "NFE for command [" + _command + "]", nfe);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("_match"))
|
||||
{
|
||||
String params = _command.substring(_command.indexOf("?") + 1);
|
||||
StringTokenizer st = new StringTokenizer(params, "&");
|
||||
int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
int heroid = Hero.getInstance().getHeroByClass(heroclass);
|
||||
if (heroid > 0)
|
||||
{
|
||||
Hero.getInstance().showHeroFights(activeChar, heroclass, heroid, heropage);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("_diary"))
|
||||
{
|
||||
String params = _command.substring(_command.indexOf("?") + 1);
|
||||
StringTokenizer st = new StringTokenizer(params, "&");
|
||||
int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
int heroid = Hero.getInstance().getHeroByClass(heroclass);
|
||||
if (heroid > 0)
|
||||
{
|
||||
Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("_olympiad?command"))
|
||||
{
|
||||
int arenaId = Integer.parseInt(_command.split("=")[2]);
|
||||
final IBypassHandler handler = BypassHandler.getInstance().getHandler("arenachange");
|
||||
if (handler != null)
|
||||
{
|
||||
handler.useBypass("arenachange " + (arenaId - 1), activeChar, null);
|
||||
}
|
||||
}
|
||||
else if (_command.startsWith("manor_menu_select"))
|
||||
{
|
||||
final L2Npc lastNpc = activeChar.getLastFolkNPC();
|
||||
if (Config.ALLOW_MANOR && (lastNpc != null) && lastNpc.canInteract(activeChar))
|
||||
{
|
||||
final String[] split = _command.substring(_command.indexOf("?") + 1).split("&");
|
||||
final int ask = Integer.parseInt(split[0].split("=")[1]);
|
||||
final int state = Integer.parseInt(split[1].split("=")[1]);
|
||||
final boolean time = split[2].split("=")[1].equals("1");
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcManorBypass(activeChar, lastNpc, ask, state, time), lastNpc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final IBypassHandler handler = BypassHandler.getInstance().getHandler(_command);
|
||||
if (handler != null)
|
||||
{
|
||||
if (bypassOriginId > 0)
|
||||
{
|
||||
L2Object bypassOrigin = activeChar.getKnownList().getKnownObjects().get(bypassOriginId);
|
||||
if ((bypassOrigin != null) && bypassOrigin.isInstanceTypes(InstanceType.L2Character))
|
||||
{
|
||||
handler.useBypass(_command, activeChar, (L2Character) bypassOrigin);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useBypass(_command, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useBypass(_command, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning(getClient() + " sent not handled RequestBypassToServer: [" + _command + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception processing bypass from player " + activeChar.getName() + ": " + _command, e);
|
||||
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(200);
|
||||
sb.append("<html><body>");
|
||||
sb.append("Bypass error: " + e + "<br1>");
|
||||
sb.append("Bypass command: " + _command + "<br1>");
|
||||
sb.append("StackTrace:<br1>");
|
||||
for (StackTraceElement ste : e.getStackTrace())
|
||||
{
|
||||
sb.append(ste.toString() + "<br1>");
|
||||
}
|
||||
sb.append("</body></html>");
|
||||
// item html
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1, sb.toString());
|
||||
msg.disableValidation();
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerBypass(activeChar, _command), activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private static void comeHere(L2PcInstance activeChar)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
L2Npc temp = (L2Npc) obj;
|
||||
temp.setTarget(activeChar);
|
||||
temp.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, activeChar.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__23_REQUESTBYPASSTOSERVER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.enums.ItemLocation;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.instancemanager.MailManager;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Message;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.ItemContainer;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExChangePostState;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Migi, DS
|
||||
*/
|
||||
public final class RequestCancelPostAttachment extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_6F_REQUESTCANCELPOSTATTACHMENT = "[C] D0:6F RequestCancelPostAttachment";
|
||||
|
||||
private int _msgId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_msgId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || !Config.ALLOW_MAIL || !Config.ALLOW_ATTACHMENTS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("cancelpost"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Message msg = MailManager.getInstance().getMessage(_msgId);
|
||||
if (msg == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (msg.getSenderId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to cancel not own post!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_IN_A_NON_PEACE_ZONE_LOCATION);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getActiveTradeList() != null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_EXCHANGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isEnchanting())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_ITEM_ENHANCEMENT_OR_ATTRIBUTE_ENHANCEMENT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_BECAUSE_THE_PRIVATE_STORE_OR_WORKSHOP_IS_IN_PROGRESS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!msg.hasAttachments())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemContainer attachments = msg.getAttachments();
|
||||
if ((attachments == null) || (attachments.getSize() == 0))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
|
||||
return;
|
||||
}
|
||||
|
||||
int weight = 0;
|
||||
int slots = 0;
|
||||
|
||||
for (L2ItemInstance item : attachments.getItems())
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getOwnerId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get not own item from cancelled attachment!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getItemLocation() != ItemLocation.MAIL)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get items not from mail !", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getLocationSlot() != msg.getId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to get items from different attachment!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
weight += item.getCount() * item.getItem().getWeight();
|
||||
if (!item.isStackable())
|
||||
{
|
||||
slots += item.getCount();
|
||||
}
|
||||
else if (activeChar.getInventory().getItemByItemId(item.getId()) == null)
|
||||
{
|
||||
slots++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().validateCapacity(slots))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().validateWeight(weight))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed to the transfer
|
||||
InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
|
||||
for (L2ItemInstance item : attachments.getItems())
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
long count = item.getCount();
|
||||
final L2ItemInstance newItem = attachments.transferItem(attachments.getName(), item.getObjectId(), count, activeChar.getInventory(), activeChar, null);
|
||||
if (newItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerIU != null)
|
||||
{
|
||||
if (newItem.getCount() > count)
|
||||
{
|
||||
playerIU.addModifiedItem(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerIU.addNewItem(newItem);
|
||||
}
|
||||
}
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S2_S1);
|
||||
sm.addItemName(item.getId());
|
||||
sm.addLong(count);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
msg.removeAttachments();
|
||||
|
||||
// Send updated item list to the player
|
||||
if (playerIU != null)
|
||||
{
|
||||
activeChar.sendPacket(playerIU);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ItemList(activeChar, false));
|
||||
}
|
||||
|
||||
// Update current load status on player
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
|
||||
final L2PcInstance receiver = L2World.getInstance().getPlayer(msg.getReceiverId());
|
||||
if (receiver != null)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANCELED_THE_SENT_MAIL);
|
||||
sm.addCharName(activeChar);
|
||||
receiver.sendPacket(sm);
|
||||
receiver.sendPacket(new ExChangePostState(true, _msgId, Message.DELETED));
|
||||
}
|
||||
|
||||
MailManager.getInstance().deleteMessageInDb(_msgId);
|
||||
|
||||
activeChar.sendPacket(new ExChangePostState(false, _msgId, Message.DELETED));
|
||||
activeChar.sendPacket(SystemMessageId.MAIL_SUCCESSFULLY_CANCELLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_6F_REQUESTCANCELPOSTATTACHMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.AbilityPointsData;
|
||||
import com.l2jserver.gameserver.enums.UserInfoType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAcquireAPSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestChangeAbilityPoint extends L2GameClientPacket
|
||||
{
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// Nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getLevel() < 99) || !activeChar.isNoble())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ABILITIES_CAN_BE_USED_BY_NOBLESSE_EXALTED_LV_99_OR_ABOVE);
|
||||
return;
|
||||
}
|
||||
|
||||
else if (activeChar.getAbilityPoints() >= Config.ABILITY_MAX_POINTS)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ACQUIRE_ANY_MORE_ABILITY_POINTS);
|
||||
return;
|
||||
}
|
||||
|
||||
long spRequired = AbilityPointsData.getInstance().getPrice(activeChar.getAbilityPoints());
|
||||
if (spRequired > activeChar.getSp())
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NEED_S1_SP_TO_CONVERT_TO1_ABILITY_POINT);
|
||||
sm.addLong(spRequired);
|
||||
activeChar.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.getStat().removeSp(spRequired))
|
||||
{
|
||||
activeChar.setAbilityPoints(activeChar.getAbilityPoints() + 1);
|
||||
final UserInfo info = new UserInfo(activeChar, false);
|
||||
info.addComponentType(UserInfoType.SLOTS, UserInfoType.CURRENT_HPMPCP_EXP_SP);
|
||||
activeChar.sendPacket(info);
|
||||
activeChar.sendPacket(new ExAcquireAPSkillList(activeChar));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
/**
|
||||
* @author ShanSoft Packets Structure: chddd
|
||||
*/
|
||||
public final class RequestChangeBookMarkSlot extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_51_05_REQUESCHANGEBOOKMARKSLOT = "[C] D0:51:05 RequestChangeBookMarkSlot";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// There is nothing to read.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_51_05_REQUESCHANGEBOOKMARKSLOT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
|
||||
/**
|
||||
* @author KenM, Gnacik
|
||||
*/
|
||||
public class RequestChangeNicknameColor extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_4F_REQUESTCHANGENICKNAMECOLOR = "[C] D0:4F RequestChangeNicknameColor";
|
||||
|
||||
private static final int COLORS[] =
|
||||
{
|
||||
0x9393FF, // Pink
|
||||
0x7C49FC, // Rose Pink
|
||||
0x97F8FC, // Lemon Yellow
|
||||
0xFA9AEE, // Lilac
|
||||
0xFF5D93, // Cobalt Violet
|
||||
0x00FCA0, // Mint Green
|
||||
0xA0A601, // Peacock Green
|
||||
0x7898AF, // Yellow Ochre
|
||||
0x486295, // Chocolate
|
||||
0x999999
|
||||
// Silver
|
||||
};
|
||||
|
||||
private int _colorNum, _itemObjectId;
|
||||
private String _title;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_colorNum = readD();
|
||||
_title = readS();
|
||||
_itemObjectId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_colorNum < 0) || (_colorNum >= COLORS.length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjectId);
|
||||
if ((item == null) || (item.getEtcItem() == null) || (item.getEtcItem().getHandlerName() == null) || !item.getEtcItem().getHandlerName().equalsIgnoreCase("NicknameColor"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.destroyItem("Consume", item, 1, null, true))
|
||||
{
|
||||
activeChar.setTitle(_title);
|
||||
activeChar.getAppearance().setTitleColor(COLORS[_colorNum]);
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_4F_REQUESTCHANGENICKNAMECOLOR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Party;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This packet is received from client when a party leader requests to change the leadership to another player in his party.
|
||||
*/
|
||||
public final class RequestChangePartyLeader extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_0C_REQUESTCHANGEPARTYLEADER = "[C] D0:0C RequestChangePartyLeader";
|
||||
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2Party party = activeChar.getParty();
|
||||
if ((party != null) && party.isLeader(activeChar))
|
||||
{
|
||||
party.changePartyLeader(_name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_0C_REQUESTCHANGEPARTYLEADER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.PetNameTable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.4.4 $ $Date: 2005/04/06 16:13:48 $
|
||||
*/
|
||||
public final class RequestChangePetName extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__93_REQUESTCHANGEPETNAME = "[C] 93 RequestChangePetName";
|
||||
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2Summon pet = activeChar.getSummon();
|
||||
if (pet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pet.isPet())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_A_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pet.getName() != null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_SET_THE_NAME_OF_THE_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PetNameTable.getInstance().doesPetNameExist(_name, pet.getTemplate().getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_ALREADY_IN_USE_BY_ANOTHER_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((_name.length() < 3) || (_name.length() > 16))
|
||||
{
|
||||
// activeChar.sendPacket(SystemMessageId.YOUR_PET_S_NAME_CAN_BE_UP_TO_8_CHARACTERS_IN_LENGTH);
|
||||
activeChar.sendMessage("Your pet's name can be up to 16 characters in length.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PetNameTable.getInstance().isValidPetName(_name))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.AN_INVALID_CHARACTER_IS_INCLUDED_IN_THE_PET_S_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
pet.setName(_name);
|
||||
pet.updateAndBroadcastStatus(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__93_REQUESTCHANGEPETNAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExIsCharNameCreatable;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RequestCharacterNameCreatable extends L2GameClientPacket
|
||||
{
|
||||
private String _name;
|
||||
private int result;
|
||||
|
||||
public static int CHARACTER_CREATE_FAILED = 1;
|
||||
public static int NAME_ALREADY_EXISTS = 2;
|
||||
public static int INVALID_LENGTH = 3;
|
||||
public static int INVALID_NAME = 4;
|
||||
public static int CANNOT_CREATE_SERVER = 5;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final int charId = CharNameTable.getInstance().getIdByName(_name);
|
||||
|
||||
if (!Util.isAlphaNumeric(_name) || !isValidName(_name))
|
||||
{
|
||||
result = INVALID_NAME;
|
||||
}
|
||||
else if (charId > 0)
|
||||
{
|
||||
result = NAME_ALREADY_EXISTS;
|
||||
}
|
||||
else if (_name.length() > 16)
|
||||
{
|
||||
result = INVALID_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
|
||||
sendPacket(new ExIsCharNameCreatable(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "[C] D0:B0 RequestCharacterNameCreatable";
|
||||
}
|
||||
|
||||
private boolean isValidName(String text)
|
||||
{
|
||||
return Config.CHARNAME_TEMPLATE_PATTERN.matcher(text).matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPutItemResultForVariationCancel;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Format(ch) d
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestConfirmCancelItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_42_REQUESTCONFIRMCANCELITEM = "[C] D0:42 RequestConfirmCancelItem";
|
||||
private int _objectId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getOwnerId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(getClient().getActiveChar(), "Warning!! Character " + getClient().getActiveChar().getName() + " of account " + getClient().getActiveChar().getAccountName() + " tryied to destroy augment on item that doesn't own.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.isAugmented())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isPvp() && !Config.ALT_ALLOW_AUGMENT_PVP_ITEMS)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
int price = 0;
|
||||
switch (item.getItem().getCrystalType())
|
||||
{
|
||||
case C:
|
||||
if (item.getCrystalCount() < 1720)
|
||||
{
|
||||
price = 95000;
|
||||
}
|
||||
else if (item.getCrystalCount() < 2452)
|
||||
{
|
||||
price = 150000;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = 210000;
|
||||
}
|
||||
break;
|
||||
case B:
|
||||
if (item.getCrystalCount() < 1746)
|
||||
{
|
||||
price = 240000;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = 270000;
|
||||
}
|
||||
break;
|
||||
case A:
|
||||
if (item.getCrystalCount() < 2160)
|
||||
{
|
||||
price = 330000;
|
||||
}
|
||||
else if (item.getCrystalCount() < 2824)
|
||||
{
|
||||
price = 390000;
|
||||
}
|
||||
else
|
||||
{
|
||||
price = 420000;
|
||||
}
|
||||
break;
|
||||
case S:
|
||||
price = 480000;
|
||||
break;
|
||||
case S80:
|
||||
case S84:
|
||||
price = 920000;
|
||||
break;
|
||||
// TODO: S84 TOP price 3.2M
|
||||
// any other item type is not augmentable
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExPutItemResultForVariationCancel(item, price));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_42_REQUESTCONFIRMCANCELITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPutCommissionResultForVariationMake;
|
||||
|
||||
/**
|
||||
* Format:(ch) dddd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestConfirmGemStone extends AbstractRefinePacket
|
||||
{
|
||||
private static final String _C__D0_28_REQUESTCONFIRMGEMSTONE = "[C] D0:28 RequestConfirmGemStone";
|
||||
private int _targetItemObjId;
|
||||
private int _refinerItemObjId;
|
||||
private int _gemstoneItemObjId;
|
||||
private long _gemStoneCount;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_targetItemObjId = readD();
|
||||
_refinerItemObjId = readD();
|
||||
_gemstoneItemObjId = readD();
|
||||
_gemStoneCount = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
|
||||
if (targetItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
|
||||
if (refinerItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
L2ItemInstance gemStoneItem = activeChar.getInventory().getItemByObjectId(_gemstoneItemObjId);
|
||||
if (gemStoneItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the item is a gemstone
|
||||
if (!isValid(activeChar, targetItem, refinerItem, gemStoneItem))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for gemstone count
|
||||
final LifeStone ls = getLifeStone(refinerItem.getId());
|
||||
if (ls == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_gemStoneCount != getGemStoneCount(targetItem.getItem().getItemGrade(), ls.getGrade()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExPutCommissionResultForVariationMake(_gemstoneItemObjId, _gemStoneCount, gemStoneItem.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_28_REQUESTCONFIRMGEMSTONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPutIntensiveResultForVariationMake;
|
||||
|
||||
/**
|
||||
* Fromat(ch) dd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class RequestConfirmRefinerItem extends AbstractRefinePacket
|
||||
{
|
||||
private static final String _C__D0_27_REQUESTCONFIRMREFINERITEM = "[C] D0:27 RequestConfirmRefinerItem";
|
||||
|
||||
private int _targetItemObjId;
|
||||
private int _refinerItemObjId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_targetItemObjId = readD();
|
||||
_refinerItemObjId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
|
||||
if (targetItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
|
||||
if (refinerItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValid(activeChar, targetItem, refinerItem))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
final int refinerItemId = refinerItem.getItem().getId();
|
||||
final CrystalType grade = targetItem.getItem().getItemGrade();
|
||||
final LifeStone ls = getLifeStone(refinerItemId);
|
||||
final int gemStoneId = getGemStoneId(grade);
|
||||
final int gemStoneCount = getGemStoneCount(grade, ls.getGrade());
|
||||
|
||||
activeChar.sendPacket(new ExPutIntensiveResultForVariationMake(_refinerItemObjId, refinerItemId, gemStoneId, gemStoneCount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_27_REQUESTCONFIRMREFINERITEM;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.ClanTable;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SiegeDefenderList;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestConfirmSiegeWaitingList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__AE_RequestConfirmSiegeWaitingList = "[C] AE RequestConfirmSiegeWaitingList";
|
||||
|
||||
private int _approved;
|
||||
private int _castleId;
|
||||
private int _clanId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_castleId = readD();
|
||||
_clanId = readD();
|
||||
_approved = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the player has a clan
|
||||
if (activeChar.getClan() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Castle castle = CastleManager.getInstance().getCastleById(_castleId);
|
||||
if (castle == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if leader of the clan who owns the castle?
|
||||
if ((castle.getOwnerId() != activeChar.getClanId()) || (!activeChar.isClanLeader()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2Clan clan = ClanTable.getInstance().getClan(_clanId);
|
||||
if (clan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!castle.getSiege().getIsRegistrationOver())
|
||||
{
|
||||
if (_approved == 1)
|
||||
{
|
||||
if (castle.getSiege().checkIsDefenderWaiting(clan))
|
||||
{
|
||||
castle.getSiege().approveSiegeDefenderClan(_clanId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((castle.getSiege().checkIsDefenderWaiting(clan)) || (castle.getSiege().checkIsDefender(clan)))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(_clanId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the defender list
|
||||
activeChar.sendPacket(new SiegeDefenderList(castle));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__AE_RequestConfirmSiegeWaitingList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPutItemResultForVariationMake;
|
||||
|
||||
/**
|
||||
* Format:(ch) d
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestConfirmTargetItem extends AbstractRefinePacket
|
||||
{
|
||||
private static final String _C__D0_26_REQUESTCONFIRMTARGETITEM = "[C] D0:26 RequestConfirmTargetItem";
|
||||
private int _itemObjId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_itemObjId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValid(activeChar, item))
|
||||
{
|
||||
// Different system message here
|
||||
if (item.isAugmented())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ONCE_AN_ITEM_IS_AUGMENTED_IT_CANNOT_BE_AUGMENTED_AGAIN);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExPutItemResultForVariationMake(_itemObjId, item.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_26_REQUESTCONFIRMTARGETITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ItemCrystalizationData;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.model.CrystalizationData;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.holders.ItemChanceHolder;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2.2.3.2.5 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestCrystallizeItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__2F_REQUESTDCRYSTALLIZEITEM = "[C] 2F RequestCrystallizeItem";
|
||||
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
|
||||
if (activeChar == null)
|
||||
{
|
||||
_log.fine("RequestCrystalizeItem: activeChar was null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize"))
|
||||
{
|
||||
activeChar.sendMessage("You are crystallizing too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count <= 0)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestCrystallizeItem] count <= 0! ban! oid: " + _objectId + " owner: " + activeChar.getName(), Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((activeChar.getPrivateStoreType() != PrivateStoreType.NONE) || !activeChar.isInCrystallize())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = activeChar.getSkillLevel(CommonSkill.CRYSTALLIZE.getId());
|
||||
if (skillLevel <= 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
if ((activeChar.getRace() != Race.DWARF) && (activeChar.getClassId().ordinal() != 117) && (activeChar.getClassId().ordinal() != 55))
|
||||
{
|
||||
_log.info("Player " + activeChar.getClient() + " used crystalize with classid: " + activeChar.getClassId().ordinal());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PcInventory inventory = activeChar.getInventory();
|
||||
if (inventory != null)
|
||||
{
|
||||
L2ItemInstance item = inventory.getItemByObjectId(_objectId);
|
||||
if (item == null)
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isHeroItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count > item.getCount())
|
||||
{
|
||||
_count = activeChar.getInventory().getItemByObjectId(_objectId).getCount();
|
||||
}
|
||||
}
|
||||
|
||||
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
|
||||
{
|
||||
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the char can crystallize items and return if false;
|
||||
boolean canCrystallize = true;
|
||||
|
||||
switch (itemToRemove.getItem().getItemGradeSPlus())
|
||||
{
|
||||
case D:
|
||||
{
|
||||
if (skillLevel < 1)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case C:
|
||||
{
|
||||
if (skillLevel < 2)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B:
|
||||
{
|
||||
if (skillLevel < 3)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
if (skillLevel < 4)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
if (skillLevel < 5)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R:
|
||||
{
|
||||
if (skillLevel < 6)
|
||||
{
|
||||
canCrystallize = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canCrystallize)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW);
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// activeChar.setInCrystallize(true);
|
||||
|
||||
// unequip if needed
|
||||
SystemMessage sm;
|
||||
if (itemToRemove.isEquipped())
|
||||
{
|
||||
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
for (L2ItemInstance item : unequiped)
|
||||
{
|
||||
iu.addModifiedItem(item);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
|
||||
if (itemToRemove.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(itemToRemove.getEnchantLevel());
|
||||
sm.addItemName(itemToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
|
||||
sm.addItemName(itemToRemove);
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
// remove from inventory
|
||||
final L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null);
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addRemovedItem(removedItem);
|
||||
activeChar.sendPacket(iu);
|
||||
|
||||
final int crystalId = itemToRemove.getItem().getCrystalItemId();
|
||||
final int crystalAmount = itemToRemove.getCrystalCount();
|
||||
|
||||
final List<ItemChanceHolder> items = new ArrayList<>();
|
||||
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
|
||||
|
||||
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
|
||||
if (data != null)
|
||||
{
|
||||
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
|
||||
}
|
||||
|
||||
for (ItemChanceHolder holder : items)
|
||||
{
|
||||
final double rand = Rnd.nextDouble() * 100;
|
||||
if (rand < holder.getChance())
|
||||
{
|
||||
// add crystals
|
||||
final L2ItemInstance createdItem = activeChar.getInventory().addItem("Crystalize", holder.getId(), holder.getCount(), activeChar, activeChar);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
|
||||
sm.addItemName(createdItem);
|
||||
sm.addLong(holder.getCount());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_CRYSTALLIZED);
|
||||
sm.addItemName(removedItem);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
activeChar.broadcastUserInfo();
|
||||
|
||||
L2World.getInstance().removeObject(removedItem);
|
||||
|
||||
activeChar.setInCrystallize(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__2F_REQUESTDCRYSTALLIZEITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponList;
|
||||
|
||||
/**
|
||||
* Format: (ch)
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public class RequestCursedWeaponList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_2A_REQUESTCURSEDWEAPONLIST = "[C] D0:2A RequestCursedWeaponList";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// nothing to read it's just a trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2Character activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// send a ExCursedWeaponList :p
|
||||
List<Integer> list = new FastList<>();
|
||||
for (int id : CursedWeaponsManager.getInstance().getCursedWeaponsIds())
|
||||
{
|
||||
list.add(id);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExCursedWeaponList(list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_2A_REQUESTCURSEDWEAPONLIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.model.CursedWeapon;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponLocation;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponLocation.CursedWeaponInfo;
|
||||
|
||||
/**
|
||||
* Format: (ch)
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestCursedWeaponLocation extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_2B_REQUESTCURSEDWEAPONLOCATION = "[C] D0:2B RequestCursedWeaponLocation";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// nothing to read it's just a trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2Character activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<CursedWeaponInfo> list = new FastList<>();
|
||||
for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
|
||||
{
|
||||
if (!cw.isActive())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Location pos = cw.getWorldPosition();
|
||||
if (pos != null)
|
||||
{
|
||||
list.add(new CursedWeaponInfo(pos, cw.getItemId(), cw.isActivated() ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
// send the ExCursedWeaponLocation
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
activeChar.sendPacket(new ExCursedWeaponLocation(list));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_2B_REQUESTCURSEDWEAPONLOCATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author ShanSoft
|
||||
* @structure: chdd
|
||||
*/
|
||||
public final class RequestDeleteBookMarkSlot extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_51_03_REQUESTDELETEBOOKMARKSLOT = "[C] D0:51:03 RequestDeleteBookMarkSlot";
|
||||
|
||||
private int id;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
id = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.teleportBookmarkDelete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_51_03_REQUESTDELETEBOOKMARKSLOT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
public final class RequestDeleteMacro extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__CE_REQUESTDELETEMACRO = "[C] CE RequestDeleteMacro";
|
||||
|
||||
private int _id;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_id = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (getClient().getActiveChar() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
getClient().getActiveChar().deleteMacro(_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__CE_REQUESTDELETEMACRO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.instancemanager.MailManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Message;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExChangePostState;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Migi, DS
|
||||
*/
|
||||
public final class RequestDeleteReceivedPost extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_68_REQUESTDELETERECEIVEDPOST = "[C] D0:68 RequestDeleteReceivedPost";
|
||||
|
||||
private static final int BATCH_LENGTH = 4; // length of the one item
|
||||
|
||||
int[] _msgIds = null;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
int count = readD();
|
||||
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_msgIds = new int[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_msgIds[i] = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || (_msgIds == null) || !Config.ALLOW_MAIL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_OR_SEND_MAIL_WITH_ATTACHED_ITEMS_IN_NON_PEACE_ZONE_REGIONS);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int msgId : _msgIds)
|
||||
{
|
||||
Message msg = MailManager.getInstance().getMessage(msgId);
|
||||
if (msg == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (msg.getReceiverId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to delete not own post!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.hasAttachments() || msg.isDeletedByReceiver())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msg.setDeletedByReceiver();
|
||||
}
|
||||
activeChar.sendPacket(new ExChangePostState(true, _msgIds, Message.DELETED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_68_REQUESTDELETERECEIVEDPOST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.instancemanager.MailManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Message;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExChangePostState;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Migi, DS
|
||||
*/
|
||||
public final class RequestDeleteSentPost extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_6D_REQUESTDELETESENTPOST = "[C] D0:6D RequestDeleteSentPost";
|
||||
|
||||
private static final int BATCH_LENGTH = 4; // length of the one item
|
||||
|
||||
int[] _msgIds = null;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
int count = readD();
|
||||
if ((count <= 0) || (count > Config.MAX_ITEM_IN_PACKET) || ((count * BATCH_LENGTH) != _buf.remaining()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_msgIds = new int[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_msgIds[i] = readD();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || (_msgIds == null) || !Config.ALLOW_MAIL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideZone(ZoneId.PEACE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_OR_SEND_MAIL_WITH_ATTACHED_ITEMS_IN_NON_PEACE_ZONE_REGIONS);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int msgId : _msgIds)
|
||||
{
|
||||
Message msg = MailManager.getInstance().getMessage(msgId);
|
||||
if (msg == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (msg.getSenderId() != activeChar.getObjectId())
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to delete not own post!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.hasAttachments() || msg.isDeletedBySender())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msg.setDeletedBySender();
|
||||
}
|
||||
activeChar.sendPacket(new ExChangePostState(false, _msgIds, Message.DELETED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_6D_REQUESTDELETESENTPOST;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.7.2.4.2.6 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestDestroyItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__60_REQUESTDESTROYITEM = "[C] 60 RequestDestroyItem";
|
||||
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count <= 0)
|
||||
{
|
||||
if (_count < 0)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestDestroyItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to destroy item with oid " + _objectId + " but has count < 0!", Config.DEFAULT_PUNISH);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("destroy"))
|
||||
{
|
||||
activeChar.sendMessage("You are destroying items too fast.");
|
||||
return;
|
||||
}
|
||||
|
||||
long count = _count;
|
||||
|
||||
if (activeChar.isProcessingTransaction() || (activeChar.getPrivateStoreType() != PrivateStoreType.NONE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
|
||||
// if we can't find the requested item, its actually a cheat
|
||||
if (itemToRemove == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cannot discard item that the skill is consuming
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
if ((activeChar.getCurrentSkill() != null) && (activeChar.getCurrentSkill().getSkill().getItemConsumeId() == itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Cannot discard item that the skill is consuming
|
||||
if (activeChar.isCastingSimultaneouslyNow())
|
||||
{
|
||||
if ((activeChar.getLastSimultaneousSkillCast() != null) && (activeChar.getLastSimultaneousSkillCast().getItemConsumeId() == itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int itemId = itemToRemove.getId();
|
||||
|
||||
if ((!activeChar.canOverrideCond(PcCondOverride.DESTROY_ALL_ITEMS) && !itemToRemove.isDestroyable()) || CursedWeaponsManager.getInstance().isCursed(itemId))
|
||||
{
|
||||
if (itemToRemove.isHeroItem())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.HERO_WEAPONS_CANNOT_BE_DESTROYED);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemToRemove.isStackable() && (count > 1))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestDestroyItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to destroy a non-stackable item with oid " + _objectId + " but has count > 1!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count > itemToRemove.getCount())
|
||||
{
|
||||
count = itemToRemove.getCount();
|
||||
}
|
||||
|
||||
if (itemToRemove.getItem().isPetItem())
|
||||
{
|
||||
if (activeChar.hasSummon() && (activeChar.getSummon().getControlObjectId() == _objectId))
|
||||
{
|
||||
activeChar.getSummon().unSummon(activeChar);
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
|
||||
{
|
||||
statement.setInt(1, _objectId);
|
||||
statement.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not delete pet objectid: ", e);
|
||||
}
|
||||
}
|
||||
if (itemToRemove.isTimeLimitedItem())
|
||||
{
|
||||
itemToRemove.endOfLife();
|
||||
}
|
||||
|
||||
if (itemToRemove.isEquipped())
|
||||
{
|
||||
if (itemToRemove.getEnchantLevel() > 0)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(itemToRemove.getEnchantLevel());
|
||||
sm.addItemName(itemToRemove);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
|
||||
sm.addItemName(itemToRemove);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
|
||||
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
for (L2ItemInstance itm : unequiped)
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
}
|
||||
|
||||
L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Destroy", itemToRemove, count, activeChar, null);
|
||||
|
||||
if (removedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
if (removedItem.getCount() == 0)
|
||||
{
|
||||
iu.addRemovedItem(removedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addModifiedItem(removedItem);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendPacket(new ItemList(activeChar, true));
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__60_REQUESTDESTROYITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.3.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
|
||||
*/
|
||||
public final class RequestDismissAlly extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__90_REQUESTDISMISSALLY = "[C] 90 RequestDismissAlly";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger packet
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!activeChar.isClanLeader())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_FEATURE_IS_ONLY_AVAILABLE_TO_ALLIANCE_LEADERS);
|
||||
return;
|
||||
}
|
||||
activeChar.getClan().dissolveAlly(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__90_REQUESTDISMISSALLY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.PartyMatchRoom;
|
||||
import com.l2jserver.gameserver.model.PartyMatchRoomList;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public class RequestDismissPartyRoom extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_0A_REQUESTDISMISSPARTYROOM = "[C] D0:0A RequestDismissPartyRoom";
|
||||
|
||||
private int _roomid;
|
||||
@SuppressWarnings("unused")
|
||||
private int _data2;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_roomid = readD();
|
||||
_data2 = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance _activeChar = getClient().getActiveChar();
|
||||
|
||||
if (_activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PartyMatchRoom _room = PartyMatchRoomList.getInstance().getRoom(_roomid);
|
||||
|
||||
if (_room == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PartyMatchRoomList.getInstance().deleteRoom(_roomid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_0A_REQUESTDISMISSPARTYROOM;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public class RequestDispel extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C_D0_4B_REQUESTDISPEL = "[C] D0:4B RequestDispel";
|
||||
|
||||
private int _objectId;
|
||||
private int _skillId;
|
||||
private int _skillLevel;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_skillId = readD();
|
||||
_skillLevel = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if ((_skillId <= 0) || (_skillLevel <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Skill skill = SkillData.getInstance().getSkill(_skillId, _skillLevel);
|
||||
if (skill == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!skill.canBeDispeled() || skill.isStayAfterDeath() || skill.isDebuff())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (skill.getAbnormalType() == AbnormalType.TRANSFORM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (skill.isDance() && !Config.DANCE_CANCEL_BUFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (activeChar.getObjectId() == _objectId)
|
||||
{
|
||||
activeChar.stopSkillEffects(true, _skillId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activeChar.hasSummon() && (activeChar.getSummon().getObjectId() == _objectId))
|
||||
{
|
||||
activeChar.getSummon().stopSkillEffects(true, _skillId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C_D0_4B_REQUESTDISPEL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.AdminTable;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.11.2.1.2.7 $ $Date: 2005/04/02 21:25:21 $
|
||||
*/
|
||||
public final class RequestDropItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__17_REQUESTDROPITEM = "[C] 17 RequestDropItem";
|
||||
|
||||
private int _objectId;
|
||||
private long _count;
|
||||
private int _x;
|
||||
private int _y;
|
||||
private int _z;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_count = readQ();
|
||||
_x = readD();
|
||||
_y = readD();
|
||||
_z = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || activeChar.isDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Flood protect drop to avoid packet lag
|
||||
if (!getClient().getFloodProtectors().getDropItem().tryPerformAction("drop item"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
|
||||
if ((item == null) || (_count == 0) || !activeChar.validateItemManipulation(_objectId, "drop") || (!Config.ALLOW_DISCARDITEM && !activeChar.canOverrideCond(PcCondOverride.DROP_ALL_ITEMS)) || (!item.isDropable() && !(activeChar.canOverrideCond(PcCondOverride.DROP_ALL_ITEMS) && Config.GM_TRADE_RESTRICTED_ITEMS)) || ((item.getItemType() == EtcItemType.PET_COLLAR) && activeChar.havePetInvItems()) || activeChar.isInsideZone(ZoneId.NO_ITEM_DROP))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
if (item.isQuestItem() && !(activeChar.canOverrideCond(PcCondOverride.DROP_ALL_ITEMS) && Config.GM_TRADE_RESTRICTED_ITEMS))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count > item.getCount())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Config.PLAYER_SPAWN_PROTECTION > 0) && activeChar.isInvul() && !activeChar.isGM())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_count < 0)
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestDropItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to drop item with oid " + _objectId + " but has count < 0!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.isStackable() && (_count > 1))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "[RequestDropItem] Character " + activeChar.getName() + " of account " + activeChar.getAccountName() + " tried to drop non-stackable item with oid " + _objectId + " but has count > 1!", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.JAIL_DISABLE_TRANSACTION && activeChar.isJailed())
|
||||
{
|
||||
activeChar.sendMessage("You cannot drop items in Jail.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getAccessLevel().allowTransaction())
|
||||
{
|
||||
activeChar.sendMessage("Transactions are disabled for your Access Level.");
|
||||
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isProcessingTransaction() || (activeChar.getPrivateStoreType() != PrivateStoreType.NONE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
|
||||
return;
|
||||
}
|
||||
if (activeChar.isFishing())
|
||||
{
|
||||
// You can't mount, dismount, break and drop items while fishing
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_FISHING2);
|
||||
return;
|
||||
}
|
||||
if (activeChar.isFlying())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Cannot discard item that the skill is consuming
|
||||
if (activeChar.isCastingNow())
|
||||
{
|
||||
if ((activeChar.getCurrentSkill() != null) && (activeChar.getCurrentSkill().getSkill().getItemConsumeId() == item.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot discard item that the skill is consuming
|
||||
if (activeChar.isCastingSimultaneouslyNow())
|
||||
{
|
||||
if ((activeChar.getLastSimultaneousSkillCast() != null) && (activeChar.getLastSimultaneousSkillCast().getItemConsumeId() == item.getId()))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DESTROYED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((L2Item.TYPE2_QUEST == item.getItem().getType2()) && !activeChar.canOverrideCond(PcCondOverride.DROP_ALL_ITEMS))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finest(activeChar.getObjectId() + ":player tried to drop quest item");
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.THAT_ITEM_CANNOT_BE_DISCARDED_OR_EXCHANGED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isInsideRadius(_x, _y, 0, 150, false, false) || (Math.abs(_z - activeChar.getZ()) > 50))
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finest(activeChar.getObjectId() + ": trying to drop too far away");
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_DISCARD_SOMETHING_THAT_FAR_AWAY_FROM_YOU);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.getInventory().canManipulateWithItemId(item.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot use this item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("requested drop item " + _objectId + "(" + item.getCount() + ") at " + _x + "/" + _y + "/" + _z);
|
||||
}
|
||||
|
||||
if (item.isEquipped())
|
||||
{
|
||||
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
for (L2ItemInstance itm : unequiped)
|
||||
{
|
||||
itm.unChargeAllShots();
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
activeChar.sendPacket(iu);
|
||||
activeChar.broadcastUserInfo();
|
||||
|
||||
ItemList il = new ItemList(activeChar, true);
|
||||
activeChar.sendPacket(il);
|
||||
}
|
||||
|
||||
L2ItemInstance dropedItem = activeChar.dropItem("Drop", _objectId, _count, _x, _y, _z, null, false, false);
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("dropping " + _objectId + " item(" + _count + ") at: " + _x + " " + _y + " " + _z);
|
||||
}
|
||||
|
||||
// activeChar.broadcastUserInfo();
|
||||
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "Drop", target, "(id: " + dropedItem.getId() + " name: " + dropedItem.getItemName() + " objId: " + dropedItem.getObjectId() + " x: " + activeChar.getX() + " y: " + activeChar.getY() + " z: " + activeChar.getZ() + ")");
|
||||
}
|
||||
|
||||
if ((dropedItem != null) && (dropedItem.getId() == Inventory.ADENA_ID) && (dropedItem.getCount() >= 1000000))
|
||||
{
|
||||
String msg = "Character (" + activeChar.getName() + ") has dropped (" + dropedItem.getCount() + ")adena at (" + _x + "," + _y + "," + _z + ")";
|
||||
_log.warning(msg);
|
||||
AdminTable.getInstance().broadcastMessageToGMs(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__17_REQUESTDROPITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean triggersOnActionRequest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.DuelManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format:(ch) ddd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestDuelAnswerStart extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_1C_REQUESTDUELANSWERSTART = "[C] D0:1C RequestDuelAnswerStart";
|
||||
private int _partyDuel;
|
||||
@SuppressWarnings("unused")
|
||||
private int _unk1;
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_partyDuel = readD();
|
||||
_unk1 = readD();
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance requestor = player.getActiveRequester();
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_response == 1)
|
||||
{
|
||||
SystemMessage msg1 = null, msg2 = null;
|
||||
if (requestor.isInDuel())
|
||||
{
|
||||
msg1 = SystemMessage.getSystemMessage(SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_ALREADY_ENGAGED_IN_A_DUEL);
|
||||
msg1.addString(requestor.getName());
|
||||
player.sendPacket(msg1);
|
||||
return;
|
||||
}
|
||||
else if (player.isInDuel())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_partyDuel == 1)
|
||||
{
|
||||
msg1 = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACCEPTED_C1_S_CHALLENGE_TO_A_PARTY_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
|
||||
msg1.addString(requestor.getName());
|
||||
|
||||
msg2 = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_DUEL_AGAINST_THEIR_PARTY_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
|
||||
msg2.addString(player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg1 = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACCEPTED_C1_S_CHALLENGE_A_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
|
||||
msg1.addString(requestor.getName());
|
||||
|
||||
msg2 = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_A_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
|
||||
msg2.addString(player.getName());
|
||||
}
|
||||
|
||||
player.sendPacket(msg1);
|
||||
requestor.sendPacket(msg2);
|
||||
|
||||
DuelManager.getInstance().addDuel(requestor, player, _partyDuel);
|
||||
}
|
||||
else if (_response == -1)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_SET_TO_REFUSE_DUEL_REQUESTS_AND_CANNOT_RECEIVE_A_DUEL_REQUEST);
|
||||
sm.addPcName(player);
|
||||
requestor.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = null;
|
||||
if (_partyDuel == 1)
|
||||
{
|
||||
msg = SystemMessage.getSystemMessage(SystemMessageId.THE_OPPOSING_PARTY_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
|
||||
msg.addPcName(player);
|
||||
}
|
||||
requestor.sendPacket(msg);
|
||||
}
|
||||
|
||||
player.setActiveRequester(null);
|
||||
requestor.onTransactionResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_1C_REQUESTDUELANSWERSTART;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExDuelAskStart;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format:(ch) Sd
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestDuelStart extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_1B_REQUESTDUELSTART = "[C] D0:1B RequestDuelStart";
|
||||
|
||||
private String _player;
|
||||
private int _partyDuel;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_player = readS();
|
||||
_partyDuel = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance activeChar = getClient().getActiveChar();
|
||||
L2PcInstance targetChar = L2World.getInstance().getPlayer(_player);
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (targetChar == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
|
||||
return;
|
||||
}
|
||||
if (activeChar == targetChar)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if duel is possible
|
||||
if (!activeChar.canDuel())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
|
||||
return;
|
||||
}
|
||||
else if (!targetChar.canDuel())
|
||||
{
|
||||
activeChar.sendPacket(targetChar.getNoDuelReason());
|
||||
return;
|
||||
}
|
||||
// Players may not be too far apart
|
||||
else if (!activeChar.isInsideRadius(targetChar, 250, false, false))
|
||||
{
|
||||
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_TOO_FAR_AWAY_TO_RECEIVE_A_DUEL_CHALLENGE);
|
||||
msg.addString(targetChar.getName());
|
||||
activeChar.sendPacket(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// Duel is a party duel
|
||||
if (_partyDuel == 1)
|
||||
{
|
||||
// Player must be in a party & the party leader
|
||||
if (!activeChar.isInParty() || !(activeChar.isInParty() && activeChar.getParty().isLeader(activeChar)))
|
||||
{
|
||||
activeChar.sendMessage("You have to be the leader of a party in order to request a party duel.");
|
||||
return;
|
||||
}
|
||||
// Target must be in a party
|
||||
else if (!targetChar.isInParty())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.SINCE_THE_PERSON_YOU_CHALLENGED_IS_NOT_CURRENTLY_IN_A_PARTY_THEY_CANNOT_DUEL_AGAINST_YOUR_PARTY);
|
||||
return;
|
||||
}
|
||||
// Target may not be of the same party
|
||||
else if (activeChar.getParty().containsPlayer(targetChar))
|
||||
{
|
||||
activeChar.sendMessage("This player is a member of your own party.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if every player is ready for a duel
|
||||
for (L2PcInstance temp : activeChar.getParty().getMembers())
|
||||
{
|
||||
if (!temp.canDuel())
|
||||
{
|
||||
activeChar.sendMessage("Not all the members of your party are ready for a duel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
L2PcInstance partyLeader = null; // snatch party leader of targetChar's party
|
||||
for (L2PcInstance temp : targetChar.getParty().getMembers())
|
||||
{
|
||||
if (partyLeader == null)
|
||||
{
|
||||
partyLeader = temp;
|
||||
}
|
||||
if (!temp.canDuel())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_OPPOSING_PARTY_IS_CURRENTLY_UNABLE_TO_ACCEPT_A_CHALLENGE_TO_A_DUEL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Send request to targetChar's party leader
|
||||
if (partyLeader != null)
|
||||
{
|
||||
if (!partyLeader.isProcessingRequest())
|
||||
{
|
||||
activeChar.onTransactionRequest(partyLeader);
|
||||
partyLeader.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine(activeChar.getName() + " requested a duel with " + partyLeader.getName());
|
||||
}
|
||||
|
||||
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_BEEN_CHALLENGED_TO_A_DUEL);
|
||||
msg.addString(partyLeader.getName());
|
||||
activeChar.sendPacket(msg);
|
||||
|
||||
msg = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_HAS_CHALLENGED_YOUR_PARTY_TO_A_DUEL);
|
||||
msg.addString(activeChar.getName());
|
||||
targetChar.sendPacket(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
|
||||
msg.addString(partyLeader.getName());
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
// 1vs1 duel
|
||||
{
|
||||
if (!targetChar.isProcessingRequest())
|
||||
{
|
||||
activeChar.onTransactionRequest(targetChar);
|
||||
targetChar.sendPacket(new ExDuelAskStart(activeChar.getName(), _partyDuel));
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine(activeChar.getName() + " requested a duel with " + targetChar.getName());
|
||||
}
|
||||
|
||||
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_BEEN_CHALLENGED_TO_A_DUEL);
|
||||
msg.addString(targetChar.getName());
|
||||
activeChar.sendPacket(msg);
|
||||
|
||||
msg = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_CHALLENGED_YOU_TO_A_DUEL);
|
||||
msg.addString(activeChar.getName());
|
||||
targetChar.sendPacket(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
|
||||
msg.addString(targetChar.getName());
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_1B_REQUESTDUELSTART;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.DuelManager;
|
||||
|
||||
/**
|
||||
* Format:(ch) just a trigger
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestDuelSurrender extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_45_REQUESTDUELSURRENDER = "[C] D0:45 RequestDuelSurrender";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
// trigger
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
DuelManager.getInstance().doSurrender(getClient().getActiveChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_45_REQUESTDUELSURRENDER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.EnchantItemData;
|
||||
import com.l2jserver.gameserver.enums.UserInfoType;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.enchant.EnchantResultType;
|
||||
import com.l2jserver.gameserver.model.items.enchant.EnchantScroll;
|
||||
import com.l2jserver.gameserver.model.items.enchant.EnchantSupportItem;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.EnchantResult;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
public final class RequestEnchantItem extends L2GameClientPacket
|
||||
{
|
||||
protected static final Logger _logEnchant = Logger.getLogger("enchant");
|
||||
|
||||
private static final String _C__5F_REQUESTENCHANTITEM = "[C] 5F RequestEnchantItem";
|
||||
|
||||
private int _objectId;
|
||||
private int _supportId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_objectId = readD();
|
||||
_supportId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if ((activeChar == null) || (_objectId == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!activeChar.isOnline() || getClient().isDetached())
|
||||
{
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ENCHANT_WHILE_OPERATING_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
|
||||
L2ItemInstance scroll = activeChar.getInventory().getItemByObjectId(activeChar.getActiveEnchantItemId());
|
||||
L2ItemInstance support = activeChar.getInventory().getItemByObjectId(activeChar.getActiveEnchantSupportItemId());
|
||||
|
||||
if ((item == null) || (scroll == null))
|
||||
{
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
// template for scroll
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
|
||||
// scroll not found in list
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// template for support item, if exist
|
||||
EnchantSupportItem supportTemplate = null;
|
||||
if (support != null)
|
||||
{
|
||||
if (support.getObjectId() != _supportId)
|
||||
{
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
return;
|
||||
}
|
||||
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
}
|
||||
|
||||
// first validation check
|
||||
if (!scrollTemplate.isValid(item, supportTemplate))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
// fast auto-enchant cheat check
|
||||
if ((activeChar.getActiveEnchantTimestamp() == 0) || ((System.currentTimeMillis() - activeChar.getActiveEnchantTimestamp()) < 2000))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " use autoenchant program ", Config.DEFAULT_PUNISH);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
// attempting to destroy scroll
|
||||
scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, activeChar, item);
|
||||
if (scroll == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
// attempting to destroy support if exist
|
||||
if (support != null)
|
||||
{
|
||||
support = activeChar.getInventory().destroyItem("Enchant", support.getObjectId(), 1, activeChar, item);
|
||||
if (support == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT2);
|
||||
Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a support item he doesn't have", Config.DEFAULT_PUNISH);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
synchronized (item)
|
||||
{
|
||||
// last validation check
|
||||
if ((item.getOwnerId() != activeChar.getObjectId()) || (item.isEnchantable() == 0))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantResultType resultType = scrollTemplate.calculateSuccess(activeChar, item, supportTemplate);
|
||||
switch (resultType)
|
||||
{
|
||||
case ERROR:
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
break;
|
||||
}
|
||||
case SUCCESS:
|
||||
{
|
||||
Skill enchant4Skill = null;
|
||||
L2Item it = item.getItem();
|
||||
// Increase enchant level only if scroll's base template has chance, some armors can success over +20 but they shouldn't have increased.
|
||||
if (scrollTemplate.getChance(activeChar, item) > 0)
|
||||
{
|
||||
item.setEnchantLevel(item.getEnchantLevel() + 1);
|
||||
item.updateDatabase();
|
||||
}
|
||||
activeChar.sendPacket(new EnchantResult(0, 0, 0, item.getEnchantLevel()));
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "Success");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
activeChar,
|
||||
item,
|
||||
scroll,
|
||||
support,
|
||||
});
|
||||
record.setLoggerName("item");
|
||||
_logEnchant.log(record);
|
||||
}
|
||||
|
||||
// announce the success
|
||||
int minEnchantAnnounce = item.isArmor() ? 6 : 7;
|
||||
int maxEnchantAnnounce = item.isArmor() ? 0 : 15;
|
||||
if ((item.getEnchantLevel() == minEnchantAnnounce) || (item.getEnchantLevel() == maxEnchantAnnounce))
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_SUCCESSFULLY_ENCHANTED_A_S2_S3);
|
||||
sm.addCharName(activeChar);
|
||||
sm.addInt(item.getEnchantLevel());
|
||||
sm.addItemName(item);
|
||||
activeChar.broadcastPacket(sm);
|
||||
|
||||
Skill skill = CommonSkill.FIREWORK.getSkill();
|
||||
if (skill != null)
|
||||
{
|
||||
activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()));
|
||||
}
|
||||
}
|
||||
|
||||
if ((item.isArmor()) && (item.getEnchantLevel() == 4) && item.isEquipped())
|
||||
{
|
||||
enchant4Skill = it.getEnchant4Skill();
|
||||
if (enchant4Skill != null)
|
||||
{
|
||||
// add skills bestowed from +4 armor
|
||||
activeChar.addSkill(enchant4Skill, false);
|
||||
activeChar.sendSkillList();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FAILURE:
|
||||
{
|
||||
if (scrollTemplate.isSafe())
|
||||
{
|
||||
// safe enchant - remain old value
|
||||
activeChar.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_SKILL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
|
||||
activeChar.sendPacket(new EnchantResult(5, 0, 0, item.getEnchantLevel()));
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "Safe Fail");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
activeChar,
|
||||
item,
|
||||
scroll,
|
||||
support,
|
||||
});
|
||||
record.setLoggerName("item");
|
||||
_logEnchant.log(record);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// unequip item on enchant failure to avoid item skills stack
|
||||
if (item.isEquipped())
|
||||
{
|
||||
if (item.getEnchantLevel() > 0)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(item.getEnchantLevel());
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
|
||||
sm.addItemName(item);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
|
||||
for (L2ItemInstance itm : unequiped)
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(iu);
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
|
||||
if (scrollTemplate.isBlessed())
|
||||
{
|
||||
// blessed enchant - clear enchant value
|
||||
activeChar.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
|
||||
|
||||
item.setEnchantLevel(0);
|
||||
item.updateDatabase();
|
||||
activeChar.sendPacket(new EnchantResult(3, 0, 0));
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "Blessed Fail");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
activeChar,
|
||||
item,
|
||||
scroll,
|
||||
support,
|
||||
});
|
||||
record.setLoggerName("item");
|
||||
_logEnchant.log(record);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// enchant failed, destroy item
|
||||
int crystalId = item.getItem().getCrystalItemId();
|
||||
int count = item.getCrystalCount() - ((item.getItem().getCrystalCount() + 1) / 2);
|
||||
if (count < 1)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
|
||||
item = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);
|
||||
if (item == null)
|
||||
{
|
||||
// unable to destroy item, cheater ?
|
||||
Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new EnchantResult(2, 0, 0));
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "Unable to destroy");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
activeChar,
|
||||
item,
|
||||
scroll,
|
||||
support,
|
||||
});
|
||||
record.setLoggerName("item");
|
||||
_logEnchant.log(record);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
L2World.getInstance().removeObject(item);
|
||||
L2ItemInstance crystals = null;
|
||||
if (crystalId != 0)
|
||||
{
|
||||
crystals = activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, item);
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
|
||||
sm.addItemName(crystals);
|
||||
sm.addLong(count);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
if (crystals != null)
|
||||
{
|
||||
iu.addItem(crystals);
|
||||
}
|
||||
}
|
||||
|
||||
if (crystalId == 0)
|
||||
{
|
||||
activeChar.sendPacket(new EnchantResult(4, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new EnchantResult(1, crystalId, count));
|
||||
}
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "Fail");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
activeChar,
|
||||
item,
|
||||
scroll,
|
||||
support,
|
||||
});
|
||||
record.setLoggerName("item");
|
||||
_logEnchant.log(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.FORCE_INVENTORY_UPDATE)
|
||||
{
|
||||
if (scroll.getCount() == 0)
|
||||
{
|
||||
iu.addRemovedItem(scroll);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addModifiedItem(scroll);
|
||||
}
|
||||
|
||||
if (item.getCount() == 0)
|
||||
{
|
||||
iu.addRemovedItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addModifiedItem(item);
|
||||
}
|
||||
|
||||
if (support != null)
|
||||
{
|
||||
if (support.getCount() == 0)
|
||||
{
|
||||
iu.addRemovedItem(support);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addModifiedItem(support);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendPacket(iu);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ItemList(activeChar, true));
|
||||
}
|
||||
|
||||
activeChar.broadcastUserInfo(UserInfoType.ENCHANTLEVEL);
|
||||
activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));
|
||||
activeChar.setActiveEnchantItemId(L2PcInstance.ID_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__5F_REQUESTENCHANTITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SecondaryAuthData;
|
||||
import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordCheck;
|
||||
|
||||
/**
|
||||
* Format: (ch)
|
||||
* @author mrTJO
|
||||
*/
|
||||
public class RequestEx2ndPasswordCheck extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_AD_REQUESTEX2NDPASSWORDCHECK = "[C] D0:AD RequestEx2ndPasswordCheck";
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!SecondaryAuthData.getInstance().isEnabled() || getClient().getSecondaryAuth().isAuthed())
|
||||
{
|
||||
sendPacket(new Ex2ndPasswordCheck(Ex2ndPasswordCheck.PASSWORD_OK));
|
||||
return;
|
||||
}
|
||||
|
||||
getClient().getSecondaryAuth().openDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_AD_REQUESTEX2NDPASSWORDCHECK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SecondaryAuthData;
|
||||
import com.l2jserver.gameserver.network.serverpackets.Ex2ndPasswordAck;
|
||||
import com.l2jserver.gameserver.security.SecondaryPasswordAuth;
|
||||
|
||||
/**
|
||||
* (ch)cS{S} c: change pass? S: current password S: new password
|
||||
* @author mrTJO
|
||||
*/
|
||||
public class RequestEx2ndPasswordReq extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_AF_REQUESTEX2NDPASSWORDREQ = "[C] D0:AF RequestEx2ndPasswordReq";
|
||||
|
||||
private int _changePass;
|
||||
private String _password, _newPassword;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_changePass = readC();
|
||||
_password = readS();
|
||||
if (_changePass == 2)
|
||||
{
|
||||
_newPassword = readS();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!SecondaryAuthData.getInstance().isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SecondaryPasswordAuth spa = getClient().getSecondaryAuth();
|
||||
boolean exVal = false;
|
||||
|
||||
if ((_changePass == 0) && !spa.passwordExist())
|
||||
{
|
||||
exVal = spa.savePassword(_password);
|
||||
}
|
||||
else if ((_changePass == 2) && spa.passwordExist())
|
||||
{
|
||||
exVal = spa.changePassword(_password, _newPassword);
|
||||
}
|
||||
|
||||
if (exVal)
|
||||
{
|
||||
getClient().sendPacket(new Ex2ndPasswordAck(Ex2ndPasswordAck.SUCCESS));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_AF_REQUESTEX2NDPASSWORDREQ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SecondaryAuthData;
|
||||
|
||||
/**
|
||||
* Format: (ch)S S: numerical password
|
||||
* @author mrTJO
|
||||
*/
|
||||
public class RequestEx2ndPasswordVerify extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_AE_REQUESTEX2NDPASSWORDVERIFY = "[C] D0:AE RequestEx2ndPasswordVerify";
|
||||
|
||||
private String _password;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_password = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!SecondaryAuthData.getInstance().isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getClient().getSecondaryAuth().checkPassword(_password, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_AE_REQUESTEX2NDPASSWORDVERIFY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2CommandChannel;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* format: (ch) d
|
||||
* @author -Wooden-
|
||||
*/
|
||||
public final class RequestExAcceptJoinMPCC extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_07_REQUESTEXASKJOINMPCC = "[C] D0:07 RequestExAcceptJoinMPCC";
|
||||
private int _response;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_response = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
L2PcInstance player = getClient().getActiveChar();
|
||||
if (player != null)
|
||||
{
|
||||
L2PcInstance requestor = player.getActiveRequester();
|
||||
SystemMessage sm;
|
||||
if (requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_response == 1)
|
||||
{
|
||||
boolean newCc = false;
|
||||
if (!requestor.getParty().isInCommandChannel())
|
||||
{
|
||||
new L2CommandChannel(requestor); // Create new CC
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_COMMAND_CHANNEL_HAS_BEEN_FORMED);
|
||||
requestor.sendPacket(sm);
|
||||
newCc = true;
|
||||
}
|
||||
requestor.getParty().getCommandChannel().addParty(player.getParty());
|
||||
if (!newCc)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_JOINED_THE_COMMAND_CHANNEL);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
requestor.sendMessage("The player declined to join your Command Channel.");
|
||||
}
|
||||
|
||||
player.setActiveRequester(null);
|
||||
requestor.onTransactionResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_07_REQUESTEXASKJOINMPCC;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExConfirmAddingContact;
|
||||
|
||||
/**
|
||||
* Format: (ch)S S: Character Name
|
||||
* @author UnAfraid & mrTJO
|
||||
*/
|
||||
public class RequestExAddContactToContactList extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_84_REQUESTEXADDCONTACTTOCONTACTLIST = "[C] D0:84 RequestExAddContactToContactList";
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
if (!Config.ALLOW_MAIL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_name == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean charAdded = activeChar.getContactList().add(_name);
|
||||
activeChar.sendPacket(new ExConfirmAddingContact(_name, charAdded));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_84_REQUESTEXADDCONTACTTOCONTACTLIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.EnchantItemData;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.enchant.EnchantScroll;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantScrollItemResult;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantSupportItemResult;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestExAddEnchantScrollItem extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_E8_REQUESTEXADDENCHANTSCROLLITEM = "[C] D0:E8 RequestExAddEnchantScrollItem";
|
||||
|
||||
private int _scrollObjectId;
|
||||
private int _enchantObjectId;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_scrollObjectId = readD();
|
||||
_enchantObjectId = readD();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.isEnchanting())
|
||||
{
|
||||
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_enchantObjectId);
|
||||
final L2ItemInstance scroll = activeChar.getInventory().getItemByObjectId(_scrollObjectId);
|
||||
|
||||
if ((item == null) || (scroll == null))
|
||||
{
|
||||
// message may be custom
|
||||
activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
activeChar.setActiveEnchantSupportItemId(L2PcInstance.ID_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
|
||||
if ((scrollTemplate == null))
|
||||
{
|
||||
// message may be custom
|
||||
activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
activeChar.setActiveEnchantSupportItemId(L2PcInstance.ID_NONE);
|
||||
activeChar.sendPacket(new ExPutEnchantSupportItemResult(0));
|
||||
return;
|
||||
}
|
||||
activeChar.sendPacket(new ExPutEnchantScrollItemResult(_scrollObjectId));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_E8_REQUESTEXADDENCHANTSCROLLITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2Party;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAskJoinMPCC;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* Format: (ch) S<br>
|
||||
* D0 0D 00 5A 00 77 00 65 00 72 00 67 00 00 00
|
||||
* @author chris_00
|
||||
*/
|
||||
public final class RequestExAskJoinMPCC extends L2GameClientPacket
|
||||
{
|
||||
private static final String _C__D0_06_REQUESTEXASKJOINMPCC = "[C] D0:06 RequestExAskJoinMPCC";
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
protected void readImpl()
|
||||
{
|
||||
_name = readS();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runImpl()
|
||||
{
|
||||
final L2PcInstance activeChar = getClient().getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(_name);
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// invite yourself? ;)
|
||||
if (activeChar.isInParty() && player.isInParty() && activeChar.getParty().equals(player.getParty()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
// activeChar is in a Party?
|
||||
if (activeChar.isInParty())
|
||||
{
|
||||
L2Party activeParty = activeChar.getParty();
|
||||
// activeChar is PartyLeader? && activeChars Party is already in a CommandChannel?
|
||||
if (activeParty.getLeader().equals(activeChar))
|
||||
{
|
||||
// if activeChars Party is in CC, is activeChar CCLeader?
|
||||
if (activeParty.isInCommandChannel() && activeParty.getCommandChannel().getLeader().equals(activeChar))
|
||||
{
|
||||
// in CC and the CCLeader
|
||||
// target in a party?
|
||||
if (player.isInParty())
|
||||
{
|
||||
// targets party already in a CChannel?
|
||||
if (player.getParty().isInCommandChannel())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_IS_ALREADY_A_MEMBER_OF_THE_COMMAND_CHANNEL);
|
||||
sm.addString(player.getName());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ready to open a new CC
|
||||
// send request to targets Party's PartyLeader
|
||||
askJoinMPCC(activeChar, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(player.getName() + " doesn't have party and cannot be invited to Command Channel.");
|
||||
}
|
||||
|
||||
}
|
||||
else if (activeParty.isInCommandChannel() && !activeParty.getCommandChannel().getLeader().equals(activeChar))
|
||||
{
|
||||
// in CC, but not the CCLeader
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_AUTHORITY_TO_INVITE_SOMEONE_TO_THE_COMMAND_CHANNEL);
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// target in a party?
|
||||
if (player.isInParty())
|
||||
{
|
||||
// targets party already in a CChannel?
|
||||
if (player.getParty().isInCommandChannel())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_PARTY_IS_ALREADY_A_MEMBER_OF_THE_COMMAND_CHANNEL);
|
||||
sm.addString(player.getName());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ready to open a new CC
|
||||
// send request to targets Party's PartyLeader
|
||||
askJoinMPCC(activeChar, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(player.getName() + " doesn't have party and cannot be invited to Command Channel.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_AUTHORITY_TO_INVITE_SOMEONE_TO_THE_COMMAND_CHANNEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void askJoinMPCC(L2PcInstance requestor, L2PcInstance target)
|
||||
{
|
||||
boolean hasRight = false;
|
||||
if (requestor.isClanLeader() && (requestor.getClan().getLevel() >= 5))
|
||||
{
|
||||
// Clan leader of lvl5 Clan or higher.
|
||||
hasRight = true;
|
||||
}
|
||||
else if (requestor.getInventory().getItemByItemId(8871) != null)
|
||||
{
|
||||
// 8871 Strategy Guide.
|
||||
// TODO: Should destroyed after successful invite?
|
||||
hasRight = true;
|
||||
}
|
||||
else if ((requestor.getPledgeClass() >= 5) && (requestor.getKnownSkill(391) != null))
|
||||
{
|
||||
// At least Baron or higher and the skill Clan Imperium
|
||||
hasRight = true;
|
||||
}
|
||||
|
||||
if (!hasRight)
|
||||
{
|
||||
requestor.sendPacket(SystemMessageId.COMMAND_CHANNELS_CAN_ONLY_BE_FORMED_BY_A_PARTY_LEADER_WHO_IS_ALSO_THE_LEADER_OF_A_LEVEL_5_CLAN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the target's party leader, and do whole actions on him.
|
||||
final L2PcInstance targetLeader = target.getParty().getLeader();
|
||||
SystemMessage sm;
|
||||
if (!targetLeader.isProcessingRequest())
|
||||
{
|
||||
requestor.onTransactionRequest(targetLeader);
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_INVITING_YOU_TO_A_COMMAND_CHANNEL_DO_YOU_ACCEPT);
|
||||
sm.addString(requestor.getName());
|
||||
targetLeader.sendPacket(sm);
|
||||
targetLeader.sendPacket(new ExAskJoinMPCC(requestor.getName()));
|
||||
|
||||
requestor.sendMessage("You invited " + targetLeader.getName() + " to your Command Channel.");
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ON_ANOTHER_TASK_PLEASE_TRY_AGAIN_LATER);
|
||||
sm.addString(targetLeader.getName());
|
||||
requestor.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return _C__D0_06_REQUESTEXASKJOINMPCC;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user