- Added all referenced libraries for eclipse to perform as it should.

- Renamed AuctionManager into ClanHallAuctionManager.
 - Created Comission (Auction house) system.
 - Reworked vitality system from account based to subclass based.
This commit is contained in:
erlandys56
2015-01-24 21:21:32 +00:00
parent 1c6301c46d
commit ebe4ba005d
46 changed files with 2684 additions and 213 deletions

View File

@@ -18,7 +18,9 @@
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.enums.ItemListType;
import com.l2jserver.gameserver.instancemanager.AuctionManager.Auctions;
import com.l2jserver.gameserver.model.ItemInfo;
import com.l2jserver.gameserver.model.TradeItem;
import com.l2jserver.gameserver.model.buylist.Product;
@@ -117,6 +119,28 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket<ItemListType
}
}
public void writeAuctionItem(Auctions auction)
{
writeQ(auction.getAuctionId()); // Auction id
writeQ(auction.getPrice()); // Price
writeD(auction.getCategory()); // Category
writeD(auction.getDuration()); // Duration / maybe in days???
writeD((int) auction.getFinishTime()); // Time when this item will vanish from auction (in seconds)(example (currentTime+60=after 1 minute))
writeS(CharNameTable.getInstance().getNameById(auction.getPlayerID())); // Name
writeD(0);
ItemInfo it = new ItemInfo(auction.getItem());
writeD(auction.getItem().getId()); // Item ID
writeQ(auction.getItem().getCount()); // Count
writeH(auction.getItem().getItem().getType2()); // item.getItem().getType2()
writeD(auction.getItem().getItem().getBodyPart()); // item.getItem().getBodyPart()
writeH(auction.getItem().getCustomType2()); // item.getCustomType2()
writeH(0x00); // ???
writeD(auction.getItem().getEnchantLevel());
writeItemElemental(it);
writeItemEnchantEffect(it);
writeD(0x00); // Item remodel visual ID
}
protected static final int calculateMask(ItemInfo item)
{
int mask = 0;

View File

@@ -236,7 +236,7 @@ public class CharSelectionInfo extends L2GameServerPacket
private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int ObjectId, int activeClassId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT exp, sp, level FROM character_subclasses WHERE charId=? && class_id=? ORDER BY charId"))
PreparedStatement statement = con.prepareStatement("SELECT exp, sp, level, vitality_points FROM character_subclasses WHERE charId=? && class_id=? ORDER BY charId"))
{
statement.setInt(1, ObjectId);
statement.setInt(2, activeClassId);
@@ -247,6 +247,7 @@ public class CharSelectionInfo extends L2GameServerPacket
charInfopackage.setExp(charList.getLong("exp"));
charInfopackage.setSp(charList.getInt("sp"));
charInfopackage.setLevel(charList.getInt("level"));
charInfopackage.setVitalityPoints(charList.getInt("vitality_points"));
}
}
}

View File

@@ -55,10 +55,10 @@ public class ExReplyReceivedPost extends AbstractItemPacket
writeC(0xFE);
writeH(0xAC);
writeD(_msg.getMailType().ordinal()); // GOD
if (_msg.getMailType() == MailType.COMMISSION_ITEM_RETURNED)
if (_msg.getMailType() == MailType.SYSTEM)
{
writeD(SystemMessageId.THE_REGISTRATION_PERIOD_FOR_THE_ITEM_YOU_REGISTERED_HAS_EXPIRED.getId());
writeD(SystemMessageId.THE_AUCTION_HOUSE_REGISTRATION_PERIOD_HAS_EXPIRED_AND_THE_CORRESPONDING_ITEM_IS_BEING_FORWARDED.getId());
writeD(_msg.getSystemMessage1());
writeD(_msg.getSystemMessage2());
}
else if (_msg.getMailType() == MailType.COMMISSION_ITEM_SOLD)
{

View File

@@ -0,0 +1,63 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.instancemanager.AuctionManager.Auctions;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
/**
* @author Erlandys
*/
public class ExResponseCommissionBuyInfo extends L2GameServerPacket
{
Auctions _auction;
public ExResponseCommissionBuyInfo(Auctions auction)
{
_auction = auction;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0xF8);
writeD(0x01); // Unknown
L2ItemInstance item = _auction.getItem();
writeQ(_auction.getPrice());
writeD(_auction.getCategory());
writeD(0x00); // Unkown
writeD(item.getId());
writeQ(item.getCount());
writeH(item.getItem().getType2());
writeD(item.getItem().getBodyPart());
writeH(item.getEnchantLevel());
writeH(item.getCustomType2());
writeD(item.getAugmentation() != null ? item.getAugmentation().getAugmentationId() : 0x00);
writeH(item.getAttackElementType());
writeH(item.getAttackElementPower());
for (byte d = 0; d < 6; d++)
{
writeH(item.getElementDefAttr(d));
}
writeH(0); // unknown
writeH(0); // unknown
writeH(0); // unknown
}
}

View File

@@ -0,0 +1,41 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Erlandys
*/
public class ExResponseCommissionBuyItem extends L2GameServerPacket
{
L2PcInstance player;
public ExResponseCommissionBuyItem(L2PcInstance _player)
{
player = _player;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0xF8);
writeD(1); // unk
writeD(0); // unk
writeD(58); // Item ID
writeQ(1); // count
}
}

View File

@@ -0,0 +1,35 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
/**
* @author Erlandys
*/
public class ExResponseCommissionDelete extends L2GameServerPacket
{
boolean success;
public ExResponseCommissionDelete(boolean _success)
{
success = _success;
}
@Override
protected final void writeImpl()
{
writeC(0xd3);
writeD(success ? 0x01 : 0x00);
}
}

View File

@@ -0,0 +1,49 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
/**
* @author Erlandys
*/
public class ExResponseCommissionInfo extends L2GameServerPacket
{
L2PcInstance player;
L2ItemInstance item;
boolean success;
public ExResponseCommissionInfo(L2PcInstance _player, int _itemOID, boolean _success)
{
player = _player;
item = player.getInventory().getItemByObjectId(_itemOID);
success = _success;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0xF4);
writeD(success ? 0x01 : 0x00); // TODO: Success
writeD(0x00); // ItemID
writeD(0x00); // TODO: Price
writeQ(0x00); // TODO: Count
writeD(0x00); // TODO: Duration
writeD(-0x01); // TODO: Unknown
writeD(0x00); // TODO: Unknown
}
}

View File

@@ -0,0 +1,49 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
/**
* @author Erlandys
*/
public class ExResponseCommissionItemList extends AbstractItemPacket
{
L2PcInstance _player;
public ExResponseCommissionItemList(L2PcInstance player)
{
_player = player;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0xF3);
writeD(_player.getInventory().getSize(false));
for (L2ItemInstance item : _player.getInventory().getItems())
{
if (!item.isSellable() || !item.isTradeable() || item.isEquipped() || (item.getId() == 57) || item.isQuestItem())
{
continue;
}
writeItem(item);
}
}
}

View File

@@ -0,0 +1,265 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.instancemanager.AuctionManager;
import com.l2jserver.gameserver.instancemanager.AuctionManager.Auctions;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
/**
* @author Erlandys
*/
public class ExResponseCommissionList extends AbstractItemPacket
{
L2PcInstance _player;
L2ItemInstance _item;
long _category;
int _type;
int _grade;
String _search;
boolean _yourAuction;
AuctionManager _am;
int _yourAuctionsSize = 0;
int _categories[][] =
{
{
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
},
{
19,
20,
21,
22,
23,
24,
25,
26,
27,
28
},
{
29,
30,
31,
32,
33,
34
},
{
35,
36,
37,
38,
39,
40
},
{
41,
42
},
{
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58
}
};
public ExResponseCommissionList(L2PcInstance player, long category, int type, int grade, String searchName)
{
_player = player;
_category = category;
_type = type;
_grade = grade;
_search = searchName;
_yourAuction = false;
_am = AuctionManager.getInstance();
}
public ExResponseCommissionList(L2PcInstance player)
{
_player = player;
_yourAuction = true;
_am = AuctionManager.getInstance();
for (Auctions auction : _am.getAuctions())
{
if (auction.getPlayerID() == player.getObjectId())
{
_yourAuctionsSize++;
}
}
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0xF7);
if (_yourAuction)
{
writeD(_yourAuctionsSize <= 0 ? -2 : 0x02);
writeD((int) (System.currentTimeMillis() / 1000));
writeD(0x00);
writeD(_yourAuctionsSize);
for (Auctions auction : _am.getAuctions())
{
if (auction.getPlayerID() == _player.getObjectId())
{
writeAuctionItem(auction);
}
}
}
else
{
writeD((_search != null) && (_category == 100) && (_am.getAuctionsSizeById(_grade, _search) > 0) ? 3 : (_am.getAuctionsSizeById(_grade, _search) <= 0) || (_am.getAuctionsSizeById(_category, _grade, _search) <= 0) ? -1 : 3);
writeD((int) (System.currentTimeMillis() / 1000));
writeD(0x00);
if (((_category > 60) && (_category < 66)) || (_category == 101))
{
writeD(_am.getAuctionsSizeById(_category, _grade, _search));
for (Auctions auction : _am.getAuctions())
{
int cat = _category == 101 ? 0 : (int) (_category % 60);
for (int ID : _categories[cat])
{
if ((_grade == -1) && _search.equals(""))
{
if (auction.getCategory() == ID)
{
writeAuctionItem(auction);
}
}
else if (_grade != -1)
{
if (_search.equals(""))
{
if ((auction.getCategory() == ID) && (_grade == auction.getItem().getItem().getCrystalType().getId()))
{
writeAuctionItem(auction);
}
}
if (!_search.equals(""))
{
if ((auction.getCategory() == ID) && (_grade == auction.getItem().getItem().getCrystalType().getId()) && auction.getItem().getName().contains(_search))
{
writeAuctionItem(auction);
}
}
}
else if (!_search.equals(""))
{
if ((auction.getCategory() == ID) && auction.getItem().getName().contains(_search))
{
writeAuctionItem(auction);
}
}
}
}
}
else if (_category < 60)
{
writeD(_am.getAuctionsSizeById(_category, _grade, _search)); // Auction count, maybe items putted in auction???
for (Auctions auction : _am.getAuctions())
{
if ((_grade == -1) && _search.equals(""))
{
if (auction.getCategory() == _category)
{
writeAuctionItem(auction);
}
}
else if (_grade != -1)
{
if (_search.equals(""))
{
if ((auction.getCategory() == _category) && (_grade == auction.getItem().getItem().getCrystalType().getId()))
{
writeAuctionItem(auction);
}
}
if (!_search.equals(""))
{
if ((auction.getCategory() == _category) && (_grade == auction.getItem().getItem().getCrystalType().getId()) && auction.getItem().getName().contains(_search))
{
writeAuctionItem(auction);
}
}
}
else if (!_search.equals(""))
{
if ((auction.getCategory() == _category) && auction.getItem().getName().contains(_search))
{
writeAuctionItem(auction);
}
}
}
}
else
{
if (_search != null)
{
writeD(_am.getAuctionsSizeById(_grade, _search)); // Auction count, maybe items putted in auction???
for (Auctions auction : _am.getAuctions())
{
if (_grade == -1)
{
if (auction.getItem().getName().contains(_search))
{
writeAuctionItem(auction);
}
}
if (_grade != -1)
{
if ((_grade == auction.getItem().getItem().getCrystalType().getId()) && auction.getItem().getName().contains(_search))
{
writeAuctionItem(auction);
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
/**
* @author Erlandys
*/
public class ExResponseCommissionRegister extends L2GameServerPacket
{
boolean success;
public ExResponseCommissionRegister(boolean _success)
{
success = _success;
}
@Override
protected final void writeImpl()
{
writeC(0xd3);
writeD(success ? 1 : 0); // Success
}
}

View File

@@ -0,0 +1,29 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
/**
* @author mrTJO
*/
public class ExShowCommission extends L2GameServerPacket
{
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0xF2);
writeD(0x01); // Just for showing window...
}
}

View File

@@ -53,9 +53,9 @@ public class ExShowReceivedPostList extends L2GameServerPacket
{
writeD(SystemMessageId.THE_ITEM_YOU_REGISTERED_HAS_BEEN_SOLD.getId());
}
else if (msg.getMailType() == MailType.COMMISSION_ITEM_RETURNED)
else if (msg.getMailType() == MailType.SYSTEM)
{
writeD(SystemMessageId.THE_REGISTRATION_PERIOD_FOR_THE_ITEM_YOU_REGISTERED_HAS_EXPIRED.getId());
writeD(msg.getSystemMessage1());
}
writeD(msg.getId());
writeS(msg.getSubject());
@@ -63,7 +63,7 @@ public class ExShowReceivedPostList extends L2GameServerPacket
writeD(msg.isLocked() ? 0x01 : 0x00);
writeD(msg.getExpirationSeconds());
writeD(msg.isUnread() ? 0x01 : 0x00);
writeD(((msg.getMailType() == MailType.COMMISSION_ITEM_SOLD) || (msg.getMailType() == MailType.COMMISSION_ITEM_RETURNED)) ? 0 : 1);
writeD(((msg.getMailType() == MailType.COMMISSION_ITEM_SOLD) || (msg.getMailType() == MailType.SYSTEM)) ? 0 : 1);
writeD(msg.hasAttachments() ? 0x01 : 0x00);
writeD(msg.isReturned() ? 0x01 : 0x00);
writeD(0x00); // SysString in some case it seems