린올 상점 추가
PacketHandler.java // 자바명
================================
case C_EXTENDED_PROTOBUF: // 검색
new C_Shop(abyte0, _client); // 추가
=============================
C_Shop // 자바명
==============================
아래 소스 넣어준다 .
package l1j.server.server.clientpackets;
import java.util.ArrayList;
import l1j.server.Config;
import l1j.server.server.GameClient;
import l1j.server.server.model.Broadcaster;
import l1j.server.server.model.L1PolyMorph;
import l1j.server.server.model.Instance.L1DollInstance;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.model.Instance.L1PetInstance;
import l1j.server.server.serverpackets.S_ChangeShape;
import l1j.server.server.serverpackets.S_CharVisualUpdate;
import l1j.server.server.serverpackets.S_ChatPacket;
import l1j.server.server.serverpackets.S_Disconnect;
import l1j.server.server.serverpackets.S_DoActionGFX;
import l1j.server.server.serverpackets.S_DoActionShop;
import l1j.server.server.serverpackets.S_PacketBox;
import l1j.server.server.serverpackets.S_ServerMessage;
import l1j.server.server.serverpackets.S_SystemMessage;
import l1j.server.server.templates.L1PrivateShopBuyList;
import l1j.server.server.templates.L1PrivateShopSellList;
public class C_Shop extends ClientBasePacket {
private static final String C_SHOP = "[C] C_Shop";
private static final int 개인상점 = 817;
public C_Shop(byte abyte0[], GameClient clientthread) {
super(abyte0);
int type = readH();
L1PcInstance pc = clientthread.getActiveChar();
if (type == 개인상점)
{
L1ItemInstance sellitem = null;
L1ItemInstance buyitem = null;
ArrayList<L1PrivateShopSellList> sellList = pc.getSellList();
ArrayList<L1PrivateShopBuyList> buyList = pc.getBuyList();
boolean tradable = true;
int sellTotalCount = 0;
int buyTotalCount = 0;
readC();
readC();
readC();
int start = readC();
if (start == 0) {
boolean next = true;
while (next) {
int subtype = readC();
if (subtype == 34) {
next = false;
continue;
}
if (subtype == 18) {
sellTotalCount++;
int totallen = readC();
int len = readC();
int sellObjectId = readK(len - 3);
readC();
int pricelen = totallen - (len + 1);
int sellPrice = readK(pricelen);
readC();
int sellCount = readC();
L1ItemInstance checkItem = pc.getInventory().getItem(sellObjectId);
if (checkItem == null) {
continue;
}
if (sellObjectId != checkItem.getId()) {
tradable = false;
pc.sendPackets(new S_SystemMessage("비정상 아이템 입니다. 다시 시도해주세요."), true);
}
if ((!checkItem.isStackable()) && (sellCount != 1)) {
tradable = false;
pc.sendPackets(new S_SystemMessage("비정상 아이템 입니다. 다시 시도해주세요."), true);
}
if (sellCount > checkItem.getCount()) {
sellCount = checkItem.getCount();
}
if ((checkItem.getCount() < sellCount) || (checkItem.getCount() <= 0) || (sellCount <= 0)) {
tradable = false;
pc.sendPackets(new S_SystemMessage("비정상 아이템 입니다. 다시 시도해주세요."), true);
}
if (checkItem.getBless() >= 128) {
tradable = false;
pc.sendPackets(new S_ServerMessage(210, checkItem.getItem().getName()));
}
if (checkItem.getEndTime() != null) { pc.sendPackets(new S_SystemMessage("시간제 아이템은 상점등록이 불가능합니다."), true);
return; }
L1DollInstance 인형 = null;
for (Object 인형오브젝트 : pc.getDollList().values()) {
if (인형오브젝트 instanceof L1DollInstance) {
인형 = (L1DollInstance) 인형오브젝트;
if (checkItem.getId() == 인형.getItemObjId()) {
tradable = false;
pc.sendPackets(new S_SystemMessage("소환중인 인형은 상점에 올릴 수 없습니다."), true);
}
}
}
if (!checkItem.getItem().isTradable()) {
tradable = false;
pc.sendPackets(new S_ServerMessage(166, checkItem.getItem().getName(), "거래 불가능합니다. "), true);
}
for (Object petObject : pc.getPetList().values()) {
if (petObject instanceof L1PetInstance) {
L1PetInstance pet = (L1PetInstance) petObject;
if (checkItem.getId() == pet.getItemObjId()) {
tradable = false;
pc.sendPackets(new S_ServerMessage(166,checkItem.getItem().getName(),"거래 불가능합니다. "), true);
break;
}
}
}
L1PrivateShopSellList pssl = new L1PrivateShopSellList();
pssl.setItemObjectId(sellObjectId);
pssl.setItemId(checkItem.getItemId());
pssl.setSellPrice(sellPrice);
pssl.setSellTotalCount(sellCount);
pssl.setUserName(pc.getName());
Config.addSellList(pssl);
sellList.add(pssl);
} else if (subtype == 26) {
buyTotalCount++;
int totallen = readC();
int len = readC();
int buyObjectId = readK(len - 3);
readC();
int pricelen = totallen - (len + 1);
int buyPrice = readK(pricelen);
readC();
int buyCount = readC();
L1ItemInstance checkItem = pc.getInventory().getItem(buyObjectId);
if (checkItem == null) {
continue;
}
if (buyObjectId != checkItem.getId()) {
tradable = false;
pc.sendPackets(new S_SystemMessage("비정상 아이템 입니다. 다시 시도해주세요."), true);
}
if ((!checkItem.isStackable()) && (buyCount != 1)) {
tradable = false;
pc.sendPackets(new S_SystemMessage("비정상 아이템 입니다. 다시 시도해주세요."), true);
}
if (buyCount > checkItem.getCount()) {
buyCount = checkItem.getCount();
}
if ((checkItem.getCount() < buyCount) || (checkItem.getCount() <= 0) || (buyCount <= 0)) {
tradable = false;
pc.sendPackets(new S_SystemMessage("비정상 아이템 입니다. 다시 시도해주세요."), true);
}
if (checkItem.getBless() >= 128) {
tradable = false;
pc.sendPackets(new S_ServerMessage(210, checkItem.getItem().getName()));
}
if (checkItem.getEndTime() != null) { pc.sendPackets(new S_SystemMessage("시간제 아이템은 상점등록이 불가능합니다."), true);
return; }
L1DollInstance 인형 = null;
for (Object 인형오브젝트 : pc.getDollList().values()) {
if (인형오브젝트 instanceof L1DollInstance) {
인형 = (L1DollInstance) 인형오브젝트;
if (checkItem.getId() == 인형.getItemObjId()) {
tradable = false;
pc.sendPackets(new S_SystemMessage("소환중인 인형은 상점에 올릴 수 없습니다."), true);
}
}
}
if (!checkItem.getItem().isTradable()) {
tradable = false;
pc.sendPackets(new S_ServerMessage(166, checkItem.getItem().getName(), "거래 불가능합니다. "), true);
}
for (Object petObject : pc.getPetList().values()) {
if (petObject instanceof L1PetInstance) {
L1PetInstance pet = (L1PetInstance) petObject;
if (checkItem.getId() == pet.getItemObjId()) {
tradable = false;
pc.sendPackets(new S_ServerMessage(166,checkItem.getItem().getName(),"거래 불가능합니다. "), true);
break;
}
}
}
L1PrivateShopBuyList psbl = new L1PrivateShopBuyList();
psbl.setItemObjectId(buyObjectId);
psbl.setItemId(checkItem.getItemId());
psbl.setBuyPrice(buyPrice);
psbl.setBuyTotalCount(buyCount);
psbl.setUserName(pc.getName());
Config.addBuyList(psbl);
buyList.add(psbl);
}
}
int len = readC();
byte[] chat = readByte(len);
readC();
int polylen = readC();
if ((sellTotalCount == 0) && (buyTotalCount == 0)) { pc.sendPackets(new S_ServerMessage(908), true);
pc.setPrivateShop(false);
pc.sendPackets(new S_DoActionGFX(pc.getId(), 3), true);
Broadcaster.broadcastPacket(pc, new S_DoActionGFX(pc.getId(), 3), true);
return; }
if (!tradable) {
Config.SellListClear(pc);
Config.BuyListClear(pc);
sellList.clear();
buyList.clear();
pc.setPrivateShop(false);
pc.sendPackets(new S_DoActionGFX(pc.getId(), 3), true);
Broadcaster.broadcastPacket(pc, new S_DoActionGFX(pc.getId(), 3), true);
return;
}
pc.getNetConnection().getAccount().updateShopOpenCount();
pc.sendPackets(new S_PacketBox(198, pc.getNetConnection().getAccount().Shop_open_count), true);
pc.setShopChat(chat);
pc.setPrivateShop(true);
pc.sendPackets(new S_DoActionShop(pc.getId(), 70, chat), true);
Broadcaster.broadcastPacket(pc, new S_DoActionShop(pc.getId(), 70, chat), true);
pc.sendPackets(new S_ChatPacket(pc, "명령어 [.무인상점] 누른후 다른 캐릭터로 접속 가능합니다"));
try
{
for (L1PrivateShopSellList pss : pc.getSellList()) {
int sellp = pss.getSellPrice();
int sellc = pss.getSellTotalCount();
sellitem = pc.getInventory().getItem(
pss.getItemObjectId());
if (sellitem == null)
continue;
pc.SaveShop(pc, sellitem, sellp, sellc, 1);
}
}
catch (Exception e) {
e.printStackTrace();
}
try
{
for (L1PrivateShopBuyList psb : pc.getBuyList()) {
int buyp = psb.getBuyPrice();
int buyc = psb.getBuyTotalCount();
buyitem = pc.getInventory().getItem(
psb.getItemObjectId());
if (buyitem == null)
continue;
pc.SaveShop(pc, buyitem, buyp, buyc, 0);
}
}
catch (Exception e) {
e.printStackTrace();
}
try
{
String polyName = readS(polylen);
int polyId = 0;
if (polyName.equalsIgnoreCase("tradezone1"))
polyId = 11326;
else if (polyName.equalsIgnoreCase("tradezone2"))
polyId = 11427;
else if (polyName.equalsIgnoreCase("tradezone3"))
polyId = 10047;
else if (polyName.equalsIgnoreCase("tradezone4"))
polyId = 9688;
else if (polyName.equalsIgnoreCase("tradezone5"))
polyId = 11322;
else if (polyName.equalsIgnoreCase("tradezone6"))
polyId = 10069;
else if (polyName.equalsIgnoreCase("tradezone7"))
polyId = 10034;
else if (polyName.equalsIgnoreCase("tradezone8")) {
polyId = 10032;
}
if (polyId != 0) {
pc.killSkillEffectTimer(67);
L1PolyMorph.undoPoly(pc);
L1ItemInstance weapon = pc.getWeapon();
if (weapon != null)
pc.getInventory().setEquipped(weapon, false, false, false);
pc.setTempCharGfx(polyId);
pc.sendPackets(new S_ChangeShape(pc.getId(), polyId, pc.getCurrentWeapon()));
if ((!pc.isGmInvis()) && (!pc.isInvisble())) {
Broadcaster.broadcastPacket(pc, new S_ChangeShape(pc.getId(), polyId));
}
S_CharVisualUpdate charVisual = new S_CharVisualUpdate(pc, 0x46);
pc.sendPackets(charVisual);
Broadcaster.broadcastPacket(pc, charVisual);
}
} catch (Exception e) {
pc.상점아이템삭제(pc.getId());
Config.SellListClear(pc);
Config.BuyListClear(pc);
sellList.clear();
buyList.clear();
pc.setPrivateShop(false);
pc.sendPackets(new S_DoActionGFX(pc.getId(), 3), true);
Broadcaster.broadcastPacket(pc, new S_DoActionGFX(pc.getId(), 3), true);
clear();
return;
}
} else if (start == 1) {
if (pc.getOnlineStatus() != 1) {
pc.sendPackets(new S_Disconnect());
return;
}
Config.SellListClear(pc);
Config.BuyListClear(pc);
sellList.clear();
buyList.clear();
pc.setPrivateShop(false);
int classId = pc.getClassId();
pc.setTempCharGfx(classId);
pc.sendPackets(new S_ChangeShape(pc.getId(), classId));
Broadcaster.broadcastPacket(pc, new S_ChangeShape(pc.getId(), classId));
L1ItemInstance weapon = pc.getWeapon();
if (weapon != null)
pc.getInventory().setEquipped(weapon, false, false, false);
S_CharVisualUpdate charVisual = new S_CharVisualUpdate(pc);
pc.sendPackets(charVisual);
Broadcaster.broadcastPacket(pc, charVisual);
}
}
}
@Override
public String getType() {
return C_SHOP;
}
}
==================
ClientBasePacket.java // 자바명
============
public int readK(int len) { // 아무대나 넣어준다
int i = 0;
switch (len) {
case 1:
i = (_decrypt[(_off++)] & 0xFF) - 128;
break;
case 2:
i = (_decrypt[(_off++)] & 0xFF) - 128;
i |= (_decrypt[(_off++)] & 0xFF) << 7;
break;
case 3:
i = (_decrypt[(_off++)] & 0xFF) - 128;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 7;
i |= (_decrypt[(_off++)] & 0xFF) << 14;
break;
case 4:
i = (_decrypt[(_off++)] & 0xFF) - 128;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 7;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 14;
i |= (_decrypt[(_off++)] & 0xFF) << 21;
break;
case 5:
i = (_decrypt[(_off++)] & 0xFF) - 128;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 7;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 14;
i |= (_decrypt[(_off++)] & 0x7F) << 21;
i |= (_decrypt[(_off++)] & 0xFF) << 28;
break;
case 6:
i = (_decrypt[(_off++)] & 0xFF) - 128;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 7;
i |= (_decrypt[(_off++)] & 0xFF) - 128 << 14;
i |= (_decrypt[(_off++)] & 0x7F) << 21;
i |= (_decrypt[(_off++)] & 0x7F) << 28;
i |= (_decrypt[(_off++)] & 0xFF) << 35;
}
return i;
}
public byte[] readByte(int len)
{
byte[] result = new byte[len];
try {
System.arraycopy(_decrypt, _off, result, 0, len);
_off += len;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
================================
L1PrivateShopBuyList.java // 자바명
==================
public L1PrivateShopBuyList() {
} // 검색 아래 넣어준다
private String _UserName; // 여기서부터
public void setUserName(String name)
{
_UserName = name;
}
public String getUserName()
{
return _UserName;
}
private int _itemId;
public void setItemId(int i)
{
_itemId = i;
}
public int getItemId() {
return _itemId;
}
==============================
Config.java //자바명
=========
// 개인상점 아무대나 넣어준다
public static void addSellList(L1PrivateShopSellList sellitem)
{
sellList.add(sellitem);
}
public static void SellListClear(L1PcInstance pc) {
for (L1PrivateShopSellList slist : pc.getSellList())
if (sellList.contains(slist))
sellList.remove(slist);
}
public static void addBuyList(L1PrivateShopBuyList buyitem)
{
buyList.add(buyitem);
}
public static void BuyListClear(L1PcInstance pc) {
for (L1PrivateShopBuyList blist : pc.getBuyList())
if (buyList.contains(blist))
buyList.remove(blist);
}
================================================
L1PrivateShopSellList.java //자바명
===============================
public L1PrivateShopSellList() {
} // 검색 아래 넣어준다
private String _UserName; // 여기부터 추가
public void setUserName(String name)
{
_UserName = name;
}
public String getUserName()
{
return _UserName;
}
private int _itemId;
public void setItemId(int i)
{
_itemId = i;
}
public int getItemId() {
return _itemId;
}
=====================================
Account.java // 자바명
=================
public static int getGamePassword() {
return _GamePassword;
} // 검색 바로 아래
public void updateShopOpenCount() { // 추가 여기서부터
Shop_open_count++;
Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
String sqlstr = "UPDATE accounts SET Shop_open_count=? WHERE login = ?";
pstm = con.prepareStatement(sqlstr);
pstm.setInt(1, Shop_open_count);
pstm.setString(2, _name);
pstm.executeUpdate();
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
===== 같은 자바위치 ====
/** 창고 비밀번호 */
private static int _GamePassword; // 검색
public int Shop_open_count; // 이것만 추가
===============================
L1PcInstance.java
==========
//
// pc의 모니터를 stop 한다.
stopEtcMonitor();
// 온라인 상태를 OFF로 해, DB에 캐릭터 정보를 기입한다
setOnlineStatus(0);
try {
save();
saveInventory();
L1BookMark.WriteBookmark(this);
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
} /// 검색 바로 아래 추가
/////////여기서 부터 추가 ...
public void 상점아이템매입삭제(int objid, int itemid, int type2) {// 아이템아이디별 판매 구매
// 구분후 삭제
Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con
.prepareStatement("DELETE FROM character_shop WHERE obj_id=? AND item_id=? AND type=?");
pstm.setInt(1, objid);
pstm.setInt(2, itemid);
pstm.setInt(3, type2);
pstm.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
public void 상점아이템삭제(int objid, int itemid, int type2) {// 아이템아이디별 판매 구매 구분후
// 삭제
Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con
.prepareStatement("DELETE FROM character_shop WHERE obj_id=? AND item_objid=? AND type=?");
pstm.setInt(1, objid);
pstm.setInt(2, itemid);
pstm.setInt(3, type2);
pstm.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
public void 상점아이템매입업데이트(int objid, int itemid, int type2, int count1) {
Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con
.prepareStatement("UPDATE character_shop SET count=? WHERE obj_id=? AND item_id=? AND type=?");
pstm.setInt(1, count1);
pstm.setInt(2, objid);
pstm.setInt(3, itemid);
pstm.setInt(4, type2);
pstm.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
public void 상점아이템업데이트(int objid, int itemid, int type2, int count1) {
Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con
.prepareStatement("UPDATE character_shop SET count=? WHERE obj_id=? AND item_objid=? AND type=?");
pstm.setInt(1, count1);
pstm.setInt(2, objid);
pstm.setInt(3, itemid);
pstm.setInt(4, type2);
pstm.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
public void 상점아이템삭제(int objid) {
Connection con = null;
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con
.prepareStatement("DELETE FROM character_shop WHERE obj_id=?");
pstm.setInt(1, objid);
pstm.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
}
public void SaveShop(L1PcInstance pc, L1ItemInstance item, int price, int sellcount, int type)
{
Connection con = null;
int bless = item.getBless();
int attr = item.getAttrEnchantLevel();
PreparedStatement pstm = null;
try {
con = L1DatabaseFactory.getInstance().getConnection();
pstm = con
.prepareStatement("INSERT INTO character_shop SET obj_id=?, char_name=?, item_objid=?, item_id=?, Item_name=?, count=?, enchant=?, price=?, type=?, locx=?, locy=?, locm=?, iden=?, attr=?");
pstm.setInt(1, pc.getId());
pstm.setString(2, pc.getName());
pstm.setInt(3, item.getId());
pstm.setInt(4, item.getItemId());
pstm.setString(5, item.getItem().getName());
pstm.setInt(6, sellcount);
pstm.setInt(7, item.getEnchantLevel());
pstm.setInt(8, price);
pstm.setInt(9, type);
pstm.setInt(10, pc.getX());
pstm.setInt(11, pc.getY());
pstm.setInt(12, pc.getMapId());
if (!item.isIdentified())
pstm.setInt(13, 0);
else {
switch (bless) {
case 0:
pstm.setInt(13, 2);
break;
case 1:
pstm.setInt(13, 1);
break;
case 2:
pstm.setInt(13, 3);
}
}
pstm.setInt(14, attr);
pstm.executeUpdate();
} catch (SQLException localSQLException) {
} catch (Exception localException) {
} finally {
SQLUtil.close(pstm);
SQLUtil.close(con);
}
} //여기까지
=================
L1PcInventory.java // 자바명
===========
public void setEquipped(L1ItemInstance item, boolean equipped) {
setEquipped(item, equipped, false, false, false);
} //검색 아래 추가
// 여기서 부터 추가
public void setEquipped(L1ItemInstance item, boolean equipped, boolean loaded, boolean changeWeapon) {
setEquipped(item, equipped, loaded, changeWeapon, false);
}
================================
나비켓 테이블 추가
========================
character_shop.sql
파일 첨부 합니다 나비켓에 읽어 오시면 됩니다..
====================
[][][][][][][][][][][][][][][][][][][][][][][][][][]
출처 : 코어팩 161114 에서 추출한거구요 (감자)
( 코어팩에 추가하신분께 깊은 감사에 말씀 드립니다)
새로운 방법으로 구현 설명 드려요
자세히 설명 드렸으니 초보자 분들도 따라서 하시면 됩니다.
다른맘은 없으니 마음껏 쓰시고 출처 달아주는 센스!!
코어팩 추출자 린올에맞게 변경- Mr. black
[][][][][][][][][][][][][][][][][][][][][][][][][][]

Eternal 님의 최근 댓글
비번이 뭐인가요? 2021 02.15 접속기 압축파일에 있을껍니다. 자바 환경변수는 네이버에 그대로 치시면 나옵니다. 2018 01.09 자바 환경변수 해줘야합니다. 자바 1.8버전입니다. 2018 01.08 1.8버전쓰시면됩니다 2018 01.08