Jump to content
  • 0

Auction Hause - Stackable items problem


Question

Posted

Hello i use this Community Auction house. When add (to auction) 100x Soul Shots and give server restart, after server restart Soul shots missing. If add any weapons or armor Auction house working fine.

 

Where can be a problem ? How can Fix them ? I thing is problem with "quantity"

 

 

package l2ro.gameserver.model.entity.auction;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import javolution.util.FastMap;
import l2ro.commons.dao.JdbcEntityState;
import l2ro.gameserver.Config;
import l2ro.gameserver.dao.ItemsDAO;
import l2ro.gameserver.data.xml.holder.HennaHolder;
import l2ro.gameserver.data.xml.holder.SoulCrystalHolder;
import l2ro.gameserver.database.DatabaseFactory;
import l2ro.gameserver.idfactory.IdFactory;
import l2ro.gameserver.model.GameObjectsStorage;
import l2ro.gameserver.model.Player;
import l2ro.gameserver.model.items.AuctionStorage;
import l2ro.gameserver.model.items.ItemAttributes;
import l2ro.gameserver.model.items.ItemInstance;
import l2ro.gameserver.model.items.ItemInstance.ItemLocation;
import l2ro.gameserver.model.items.PcInventory;
import l2ro.gameserver.templates.item.ArmorTemplate.ArmorType;
import l2ro.gameserver.templates.item.EtcItemTemplate.EtcItemType;
import l2ro.gameserver.templates.item.ItemTemplate;
import l2ro.gameserver.templates.item.WeaponTemplate.WeaponType;
import l2ro.gameserver.utils.ItemFunctions;
import l2ro.gameserver.utils.Log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AuctionManager
{

	private static AuctionManager _instance;
	private static final Logger _log = LoggerFactory.getLogger(AuctionManager.class);
	
	private Map<Integer, Auction> _auctions = new FastMap<>();
	private Map<Integer, Long> _lastMadeAuction = new FastMap<>();
	private List<Integer> _deadAuctions = new ArrayList<>();
	private int _lastId = -1;
	
	private AuctionManager()
	{
		loadAuctions();
		checkTooOldAuctions();
	}

	public Auction getAuction(int auctionId)
	{
		return _auctions.get(auctionId);
	}
	
	public Auction getAuction(ItemInstance item)
	{
		for (Auction auction : getAllAuctions())
		{
			if (auction.getItem().equals(item))
				return auction;
		}
		return null;
	}
	
	public Collection<Auction> getAllAuctions()
	{
		return _auctions.values();
	}
	
	public Collection<Auction> getMyAuctions(Player player)
	{
		return getMyAuctions(player.getObjectId());
	}
	
	public Collection<Auction> getMyAuctions(int playerObjectId)
	{
		Collection<Auction> coll = new ArrayList<>();
		for (Auction auction : getAllAuctions())
		{
			if (auction.getSellerObjectId() == playerObjectId)
				coll.add(auction);
		}
		return coll;
	}
	
	private void loadAuctions()
	{
		AuctionStorage.getInstance();
		try (Connection con = DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement("SELECT * FROM auctions");
				ResultSet rset = statement.executeQuery())
		{
			while (rset.next())
			{
				int id = rset.getInt("auction_id");
				int sellerObjectId = rset.getInt("seller_object_id");
				String sellerName = rset.getString("seller_name");
				int itemObjectId = rset.getInt("item_object_id");
				long pricePerItem = rset.getLong("price_per_item");
				ItemInstance item = AuctionStorage.getInstance().getItemByObjectId(itemObjectId);
				//Saving last Id
				if (id > _lastId)
					_lastId = id;

				if (item != null)
				{
					Auction auction = new Auction(id, sellerObjectId, sellerName, item, pricePerItem, item.getCount(), getItemGroup(item));
					_auctions.put(id, auction);
					_log.info("Loaded Auction: ID " +id+ "SellerName: " +sellerName+ "item Id: " + item.getItemId() + "count: " + item.getCount());
				}
				else
				{
					_deadAuctions.add(id);
				}
			}
		}
		catch (SQLException e)
		{
			_log.error("Error while loading Auctions", e);
		}
	}
	
	public void addAuctionToDatabase(Auction auction)
	{
		try (Connection con = DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement("INSERT INTO auctions VALUES(?,?,?,?,?)"))
		{
			statement.setInt(1, auction.getAuctionId());
			statement.setInt(2, auction.getSellerObjectId());
			statement.setString(3, auction.getSellerName());
			statement.setInt(4, auction.getItem().getObjectId());
			statement.setLong(5, auction.getPricePerItem());
			statement.execute();
		}
		catch(Exception e)
		{
			_log.error("Error while adding auction to database:", e);
		}
	}
	
	private void checkTooOldAuctions() //TODO maybe make it in one statement?
	{
		List<Integer> auctionOwners = new ArrayList<>();
		for (Auction auction : getAllAuctions())
		{
			if (!auctionOwners.contains(auction.getSellerObjectId()))
				auctionOwners.add(auction.getSellerObjectId());
		}
		List<Auction> auctionsToRemove = new ArrayList<>();
		
		try (Connection con = DatabaseFactory.getInstance().getConnection())
		{
			for (Integer obj_Id : auctionOwners)
			{
				try (PreparedStatement statement = con.prepareStatement("SELECT lastAccess FROM characters WHERE obj_Id=?"))
				{
					statement.setInt(1, obj_Id);
					
					try (ResultSet rset = statement.executeQuery())
					{
						if (rset.next())
						{
							long lastAccess = rset.getInt("lastAccess");
							if ((lastAccess * 1000 + Config.AUCTION_INACTIVITY_DAYS_TO_DELETE * 86400000) < System.currentTimeMillis()) // If his last logged date was at least 7 days ago
							{
								for (Auction auction : getMyAuctions(obj_Id)) 
									auctionsToRemove.add(auction);
								    Log.LogAuctionHauseDelete(" after " + Config.AUCTION_INACTIVITY_DAYS_TO_DELETE + "day has bean deleted :", "AUCTION DELETE: ", getAuction(0));;

							}
						}
					}
				}
			}
		}
		catch (Exception e)
		{
			_log.error("", e);
		}
		
		for (Auction auction : auctionsToRemove)
		{
			deleteAuctionFromDatabase(auction);
			_auctions.remove(auction.getAuctionId());
			ItemInstance item = auction.getItem();
			item.setLocation(ItemLocation.INVENTORY);
			item.setOwnerId(auction.getSellerObjectId());
			item.setJdbcState(JdbcEntityState.UPDATED);
			item.update();
			AuctionStorage.getInstance().deleteItemFromList(item);
		}
	}
	
	/**
	 * Adding adena by database
	 */
	public void addAdenaToSeller(int sellerObjectId, long adena)
	{
		ItemInstance item = ItemFunctions.createItem(57);
		item.setCount(adena);
		item.setOwnerId(sellerObjectId);
		item.setLocation(ItemLocation.INVENTORY);
		ItemsDAO.getInstance().save(item);
	}
	
	public void deleteAuctionFromDatabase(Auction auction)
	{
		try (Connection con = DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement("DELETE FROM auctions WHERE auction_id = ?"))
		{
			statement.setInt(1, auction.getAuctionId());
			statement.execute();
		}
		catch (SQLException e)
		{
			_log.error("Error while deleting auction from database:", e);
		}
	}
	
	public void deleteAuction(Player seller, ItemInstance item)
	{
		Auction auction = null;
		for (Auction anyAuction : getMyAuctions(seller))
		{
			if (anyAuction.getItem().equals(item))
			{
				auction = anyAuction;
				break;
			}
		}
		if (auction == null)
		{
			sendMessage(seller, "This auction doesn't exist anymore!");
			return;
		}
		if (!Config.ALLOW_AUCTION_OUTSIDE_TOWN && !seller.isInPeaceZone())
		{
			sendMessage(seller, "You cannot delete auction outside town!");
		}
		_auctions.remove(auction.getAuctionId());
		PcInventory inventory = seller.getInventory();
		AuctionStorage storage = AuctionStorage.getInstance();
		inventory.writeLock();
		storage.writeLock();
		try
		{
			inventory.addItem(item);
			storage.removeItem(item);
		}
		finally
		{
			storage.writeUnlock();
			inventory.writeUnlock();
		}
		
		seller.sendChanges();
		
		deleteAuctionFromDatabase(auction);
		
		sendMessage(seller, "Auction has been removed!");
		
		Log.LogAction(seller, "Auction", "Deleted Auction. Item:" + item.getName() + " Count:" + item.getCount());
		Log.LogAuctionHause(" Deleted Auction. Item: " +  item.getName() +  " Aution ID - " + auction.getAuctionId() +  "", "AUCTION: ", seller);
	}
	
	public void buyItem(Player buyer, ItemInstance item, int quantity)
	{
		Auction auction = getAuction(item);
		if (auction == null)
		{
			sendMessage(buyer, "This auction doesn't exist anymore!");
			return;
		}
		if (auction.getSellerObjectId() == buyer.getObjectId())
		{
			sendMessage(buyer, "You cannot win your own auction!");
			return;
		}
		if (item.getCount() < quantity)
		{
			sendMessage(buyer, "You are trying to buy too many items!");
			return;
		}
		if (auction.getPricePerItem() * quantity > buyer.getAdena())
		{
			sendMessage(buyer, "You don't have enough adena!");
			return;
		}
		if (!Config.ALLOW_AUCTION_OUTSIDE_TOWN && !buyer.isInPeaceZone())
		{
			sendMessage(buyer, "You cannot use buy that item outside town!");
			return;
		}
		
		buyer.getInventory().reduceAdena(auction.getPricePerItem() * quantity);
		boolean wholeItemBought = false;
		
		PcInventory inventory = buyer.getInventory();
		AuctionStorage storage = AuctionStorage.getInstance();
		inventory.writeLock();
		storage.writeLock();
		try
		{
			if (item.getCount() == quantity)
			{
				item.setOwnerId(buyer.getObjectId());
				storage.removeItem(item);
				inventory.addItem(item);
				
				deleteAuctionFromDatabase(auction);
				_auctions.remove(auction.getAuctionId());
				wholeItemBought = true;
			}
			else
			{
				ItemInstance newItem = copyItem(item, quantity);
				newItem.setOwnerId(buyer.getObjectId());
				storage.removeItem(item, quantity);
				inventory.addItem(newItem);
				inventory.refreshEquip();
				auction.setCount(auction.getCountToSell()-quantity);

			}
		}
		finally
		{
			storage.writeUnlock();
			inventory.writeUnlock();
		}
		
		buyer.sendChanges();
		
		Player seller = GameObjectsStorage.getPlayer(auction.getSellerObjectId());
		if (seller != null)
		{
			if (wholeItemBought) 
				seller.sendMessage(item.getName() + " has been bought by " + buyer.getName() + "!");
			else
				seller.sendMessage(quantity + " " + item.getName() + (quantity > 1 ? "s" : "") + " has been bought by " + buyer.getName() + "!");
			seller.addAdena(auction.getPricePerItem()*quantity, true);
			
			Log.LogAction(seller, "Auction", "Sold Item:"+item.getName()+" Count:"+item.getCount());
			Log.LogAuctionHause(" Sold Item: " +  item.getName() +  " Aution ID - " + auction.getAuctionId() +  " Count: " + quantity + "buy by" + buyer.getName() + "", "AUCTION: ", seller);

		}
		else
		{
			addAdenaToSeller(auction.getSellerObjectId(), auction.getPricePerItem() * quantity);
		}
		
		Log.LogAction(buyer, "Auction", "Bought Item:" + item.getName() + " Count:" + item.getCount() + " Cost:" + auction.getPricePerItem() * quantity);
		
		buyer.sendMessage("You have bought " + item.getName());
		Log.LogAuctionHause(" obtain " + item.getName() + " Count: " + quantity + " auction id " + auction.getAuctionId() + "" , "AUCTION: ", buyer);

	}
	
	public void checkAndAddNewAuction(Player seller, ItemInstance item,  long quantity, long salePrice)
	{
		if (!checkIfItsOk(seller, item, quantity, salePrice))
			return;
		
		int id = getNewId();
		if (id < 0)
		{
			sendMessage(seller, "There are currently too many auctions!");
			return;
		}
		
		AuctionItemTypes type = getItemGroup(item);

		PcInventory inventory = seller.getInventory();
		AuctionStorage storage = AuctionStorage.getInstance();
		
		Auction auction = null;
		
		inventory.writeLock();
		storage.writeLock();
		try
		{
			if (item.getCount() > quantity)
			{
				ItemInstance newItem = copyItem(item, quantity);
				seller.getInventory().removeItem(item, quantity);
				inventory.refreshEquip();
				storage.addItem(newItem);
				auction = addAuction(seller, id, newItem, salePrice, quantity, type);
				Log.LogAuctionHause("AuctionStorage 1: " +  item.getName() +  " Aution ID - " + item.getItemId() +  " Count: " + item.getCount(), "AUCTION: ", seller);

			}
			else
			{
				inventory.removeItem(item);
				item.setCount(quantity);
				storage.addFullItem(item);
				auction = addAuction(seller, id, item, salePrice, quantity, type);
				Log.LogAuctionHause("AuctionStorage 2: " +  item.getName() +  " Aution ID - " + item.getItemId() +  " Count: " + item.getCount(), "AUCTION: ", seller);

			}
		}
		finally
		{
			storage.writeUnlock();
			inventory.writeUnlock();
		}
		
		seller.sendChanges();
		_lastMadeAuction.put(seller.getObjectId(), System.currentTimeMillis() + Config.SECONDS_BETWEEN_ADDING_AUCTIONS * 1000);
		
		seller.getInventory().reduceAdena(Config.AUCTION_FEE);
		addAuctionToDatabase(auction);
		sendMessage(seller, "Auction has been created!");
		
		Log.LogAction(seller, "Auction", "Added Auction. Item:" + item.getName() + " Count:" + item.getCount() + " Total Cost:" + auction.getPricePerItem() * quantity);
		Log.LogAuctionHause(" create auction " + auction.getAuctionId() + " item: " +  item.getName()  + " Count: " + quantity + " Total Cost: " + auction.getPricePerItem() * quantity + "" , "AUCTION: ", seller);

	}
	
	private Auction addAuction(Player seller, int auctionId, ItemInstance item, long salePrice, long sellCount, AuctionItemTypes itemType)
	{
		
		Auction newAuction = new Auction(auctionId, seller.getObjectId(), seller.getName(), item, salePrice, sellCount, itemType);
		_auctions.put(auctionId, newAuction);
		
		return newAuction;
	}
	
	public void sendMessage(Player player, String message)
	{
		player.sendMessage(message);
	}
	
	private ItemInstance copyItem(ItemInstance oldItem, long quantity)
	{
		ItemInstance item = new ItemInstance(IdFactory.getInstance().getNextId(), oldItem.getItemId());
		item.setOwnerId(-1);
		item.setCount(quantity);
		item.setEnchantLevel(oldItem.getEnchantLevel());
		item.setLocation(ItemLocation.VOID);
		item.setLocData(-1);
		item.setCustomType1(oldItem.getCustomType1());
		item.setCustomType2(oldItem.getCustomType2());
		item.setLifeTime(oldItem.getLifeTime());
		item.setCustomFlags(oldItem.getCustomFlags());
		item.setAugmentationId(oldItem.getAugmentationId());
		
		ItemAttributes oldAtt = oldItem.getAttributes();
		ItemAttributes att = new ItemAttributes(oldAtt.getFire(), oldAtt.getWater(), oldAtt.getWind(), oldAtt.getEarth(), oldAtt.getHoly(), oldAtt.getUnholy());
		item.setAttributes(att);
		
		item.setAgathionEnergy(oldItem.getAgathionEnergy());
		item.setLocation(ItemLocation.VOID);
		
		return item;
	}

	private int getNewId()
	{
		return ++_lastId;
	}
	
	private boolean checkIfItsOk(Player seller, ItemInstance item, long quantity, long salePrice)
	{
		if (seller == null)
			return false;
		if (item == null)
		{
			sendMessage(seller, "The item you are trying to sell, doesn't exist!");
			return false;
		}
		
		if (item.getLocation() != ItemInstance.ItemLocation.INVENTORY)
		{
			sendMessage(seller, "The item should be at your inventory!");
			return false;
		}
		
		if (item.getOwnerId() != seller.getObjectId())
		{
			sendMessage(seller, "The item you are trying to sell is no longer yours!");
			return false;
		}
		
		if (item.isEquipped())
		{
			sendMessage(seller, "You need to unequip that item first!");
			return false;
		}
		
		if (item.isAugmented())
		{
			sendMessage(seller, "You cannot sell Augmented weapons!");
			return false;
		}
		
		if (!item.canBeSold(seller))
		{
			sendMessage(seller, "You can't sell this item!");
			return false;
		}

		if (!item.canBeTraded(seller))
		{
			sendMessage(seller, "You can't sell this item!");
			return false;
		}
		
		if (seller.isInStoreMode())
		{
			sendMessage(seller, "You can't auction an item while in store mode!");
			return false;
		}
		
		if (item.getTemplate().isQuest())
		{
			sendMessage(seller, "You can't sell quest items!");
			return false;
		}
		
		if (seller.getPet() != null && item.getItemType() == EtcItemType.PET_COLLAR)
		{
			sendMessage(seller, "Please unsummon your pet before trying to sell this item.");
			return false;
		}
		
		if (seller.getPet() != null && item.isSummon() && item.getTemplate().isForPet())
		{
			sendMessage(seller, "Please unsummon your pet before trying to sell this item.");
			return false;
		}
		
		if (quantity < 1)
		{
			sendMessage(seller, "Quantity is too low!");
			return false;
		}
		
		if (item.getCount() < quantity)
		{
			sendMessage(seller, "You don't have enough items to sell!");
			return false;
		}
		
		if (seller.getAdena() < Config.AUCTION_FEE)
		{
			sendMessage(seller, "You don't have enough adena, to pay the fee!");
			return false;
		}
		
		if (salePrice <= 0)
		{
			sendMessage(seller, "Sale price is too low!");
			return false;
		}
		
		if (salePrice > 999999999999L)
		{
			sendMessage(seller, "Price is too high!");
			return false;
		}
		
		if (getMyAuctions(seller).size() >= 10)
		{
			sendMessage(seller, "You can have just 10 auctions at the time!");
			return false;
		}
		
		if (!Config.ALLOW_AUCTION_OUTSIDE_TOWN && !seller.isInPeaceZone())
		{
			sendMessage(seller, "You cannot add new auction outside town!");
			return false;
		}
		
        if (item.isStackable())
        {
            for (Auction playerAuction : AuctionManager.getInstance().getMyAuctions(seller))
            {
                if (playerAuction.getItem().getItemId() == item.getItemId())

                {
                    sendMessage(seller, "You can't sell same stackable item in auctions");
                    return false;
                }
            }
        }
		
		if (_lastMadeAuction.containsKey(seller.getObjectId()))
		{
			if (_lastMadeAuction.get(seller.getObjectId()) > System.currentTimeMillis())
			{
				sendMessage(seller, "You cannot do it so often!");
				return false;
			}
		}
		return true;
	}
	
	private AuctionItemTypes getItemGroup(ItemInstance item)
	{
		if (item.isEquipable())
		{
			if (item.getBodyPart() == (ItemTemplate.SLOT_L_EAR | ItemTemplate.SLOT_R_EAR))
				return AccessoryItemType.Earring;
			if (item.getBodyPart() == (ItemTemplate.SLOT_L_FINGER | ItemTemplate.SLOT_R_FINGER))
				return AccessoryItemType.Ring;
			if (item.getBodyPart() == ItemTemplate.SLOT_NECK)
				return AccessoryItemType.Necklace;
			if (item.getBodyPart() == ItemTemplate.SLOT_L_BRACELET || item.getBodyPart() == ItemTemplate.SLOT_R_BRACELET)
				return AccessoryItemType.Bracelet;
			if (item.getBodyPart() == ItemTemplate.SLOT_HAIR || item.getBodyPart() == ItemTemplate.SLOT_HAIRALL || item.getBodyPart() == ItemTemplate.SLOT_DHAIR)
				return AccessoryItemType.Accessory;
		}
		
		if (item.isArmor())
		{
			if (item.getBodyPart() == ItemTemplate.SLOT_HEAD)
				return ArmorItemType.Helmet;
			if (item.getBodyPart() == ItemTemplate.SLOT_CHEST)
				return ArmorItemType.Chest;
			if (item.getBodyPart() == ItemTemplate.SLOT_LEGS)
				return ArmorItemType.Legs;
			if (item.getBodyPart() == ItemTemplate.SLOT_GLOVES)
				return ArmorItemType.Gloves;
			if (item.getBodyPart() == ItemTemplate.SLOT_FEET)
				return ArmorItemType.Shoes;
			if (item.getTemplate().isCloak())
				return ArmorItemType.Cloak;
			if (item.getTemplate().isUnderwear())
				return ArmorItemType.Shirt;
			if (item.getTemplate().isBelt())
				return ArmorItemType.Belt;
		}
		if (item.getTemplate().isEnchantScroll())
			return EtcAuctionItemType.Enchant;
		if (item.getTemplate().isLifeStone())
			return EtcAuctionItemType.Life_stone;
		if (item.getTemplate().isAttributeCrystal() || item.getTemplate().isAttributeStone())
			return EtcAuctionItemType.Attribute;
		if (item.getTemplate().isCodexBook())
			return EtcAuctionItemType.Codex;
		if (item.getTemplate().isForgottenScroll())
			return EtcAuctionItemType.Forgotten_scroll;
		if (SoulCrystalHolder.getInstance().getCrystal(item.getItemId()) != null)
			return EtcAuctionItemType.SA_crystal;
		
		if (item.isPet())
			return PetItemType.Pet;
		if (item.getItemType() == EtcItemType.PET_COLLAR)
			return PetItemType.Pet;
		if (item.getTemplate().isForPet())
			return PetItemType.Gear;
		if (isBabyFoodOrShot(item.getItemId()))
			return PetItemType.Other;
		
		if (item.getItemType() == EtcItemType.POTION)
			return SuppliesItemType.Elixir;
		if (HennaHolder.getInstance().isHenna(item.getItemId()))
			return SuppliesItemType.Dye;
		if (item.getItemType() == EtcItemType.SCROLL)
			return SuppliesItemType.Scroll;
		if (item.getTemplate().isKeyMatherial())
			return SuppliesItemType.Key_Material;
		if (item.getTemplate().isRecipe())
			return SuppliesItemType.Recipe;
		if (item.getItemType() == EtcItemType.MATERIAL)
			return SuppliesItemType.Material;
		if (item.getItemType() instanceof EtcItemType)
			return SuppliesItemType.Miscellaneous;
		
		if (item.isWeapon())
		{
			if (item.getItemType() == WeaponType.SWORD)
				return WeaponItemType.Sword;
			if (item.getItemType() == WeaponType.ANCIENTSWORD)
				return WeaponItemType.Ancient_sword;
			if (item.getItemType() == WeaponType.BIGSWORD)
				return WeaponItemType.Big_sword;
			if (item.getItemType() == WeaponType.BLUNT)
				return WeaponItemType.Blunt;
			if (item.getItemType() == WeaponType.BIGBLUNT)
				return WeaponItemType.Big_blunt;
			if (item.getItemType() == WeaponType.DAGGER)
				return WeaponItemType.Dagger;
			if (item.getItemType() == WeaponType.DUALDAGGER)
				return WeaponItemType.Dual_dagger;
			if (item.getItemType() == WeaponType.BOW)
				return WeaponItemType.Bow;
			if (item.getItemType() == WeaponType.CROSSBOW)
				return WeaponItemType.Crossbow;
			if (item.getItemType() == WeaponType.POLE)
				return WeaponItemType.Pole;
			if (item.getItemType() == WeaponType.DUALFIST)
				return WeaponItemType.Fists;
			if (item.getItemType() == WeaponType.RAPIER)
				return WeaponItemType.Rapier;
			return WeaponItemType.Other;
		}
		
		if (item.getBodyPart() == ItemTemplate.SLOT_L_HAND)
		{
			if (item.getItemType() == ArmorType.SIGIL)
				return ArmorItemType.Sigil;
			else
				return ArmorItemType.Shield;
		}
		
		return SuppliesItemType.Miscellaneous;
	}
	
	private static final int[] PET_FOOD_OR_SHOT = { 6316, 2515, 4038, 5168, 5169, 7582, 9668, 10425, 6645, 20332, 20329, 20326, 10515, 6647, 6646, 20334, 20333, 20331, 20330, 20329, 20327, 10517, 10516 };
	
	private boolean isBabyFoodOrShot(int id)
	{
		for (int i : PET_FOOD_OR_SHOT)
		{
			if (i == id)
				return true;
		}
		return false;
	}
	
	public static AuctionManager getInstance()
	{
		if (_instance == null)
			_instance = new AuctionManager();
		return _instance;
	}
}

 

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Where I can buy a cheap domain .com? cheapest I found was on Godaddy for 12 euro and Hostinger for 10 euro.
    • Hello everyone, here's a simple and useful idea for any type of server.   This code applies a discount when a player makes a purchase inside a clan’s castle or clan hall, offering a benefit to clan members who own a castle or clan hall. Important: Merchant transactions must be handled through multisell, not buylist. The discount is directly applied within the multisell, so the price shown is already reduced.   "For example, if a scroll costs 1000 Adena and you set a 20% discount in the config, the final price when purchasing inside a castle or clan hall will be 800 Adena."   This code is developed on the public aCis 401 revision.   public static int CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT; CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT = clans.getProperty("ClanBaseOwnershipMechantDiscount", 20); # If clan owns a clan hall or castle, all members have a discount of X% at merchant transactions (multisell). # Discount applies only inside the base (castle or clan hall). ClanBaseOwnershipMechantDiscount = 20   /** diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java b/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java index 556e111..bbf8e69 100644 --- a/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java @@ -101,7 +101,7 @@ do { // send list at least once even if size = 0 - player.sendPacket(new MultiSellList(list, index)); + player.sendPacket(new MultiSellList(list, index, player)); index += PAGE_SIZE; } while (index < list.getEntries().size()); diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java index 7c82c5b..1654abc 100644 --- a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java @@ -6,6 +6,7 @@ import net.sf.l2j.Config; import net.sf.l2j.gameserver.enums.FloodProtector; import net.sf.l2j.gameserver.enums.StatusType; +import net.sf.l2j.gameserver.enums.ZoneId; import net.sf.l2j.gameserver.enums.items.CrystalType; import net.sf.l2j.gameserver.model.Augmentation; import net.sf.l2j.gameserver.model.actor.Player; @@ -225,6 +226,20 @@ return; } + if (player.isInsideZone(ZoneId.CLAN_HALL) && player.getClan() != null && player.getClan().hasClanHall()) + { + e.setItemCount(e.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100); + if (e.getItemCount() == 0) + e.setItemCount(1); + } + + if (player.isInsideZone(ZoneId.CASTLE) && player.getClan() != null && player.getClan().hasCastle()) + { + e.setItemCount(e.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100); + if (e.getItemCount() == 0) + e.setItemCount(1); + } + if (Config.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 diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java index 9269b06..c6102a0 100644 --- a/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java @@ -2,6 +2,9 @@ import static net.sf.l2j.gameserver.data.xml.MultisellData.PAGE_SIZE; +import net.sf.l2j.Config; +import net.sf.l2j.gameserver.enums.ZoneId; +import net.sf.l2j.gameserver.model.actor.Player; import net.sf.l2j.gameserver.model.multisell.Entry; import net.sf.l2j.gameserver.model.multisell.Ingredient; import net.sf.l2j.gameserver.model.multisell.ListContainer; @@ -15,7 +18,9 @@ private boolean _finished; - public MultiSellList(ListContainer list, int index) + private Player _player; + + public MultiSellList(ListContainer list, int index, Player player) { _list = list; _index = index; @@ -28,6 +33,8 @@ } else _finished = true; + + _player = player; } @Override @@ -74,7 +81,14 @@ { writeH(ing.getItemId()); writeH(ing.getTemplate() != null ? ing.getTemplate().getType2() : 65535); - writeD(ing.getItemCount()); + + if (_player.isInsideZone(ZoneId.CLAN_HALL) && _player.getClan() != null && _player.getClan().hasClanHall()) + writeD((ing.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100) < 1 ? 1 : ing.getItemCount() * 80 / 100); + else if (_player.isInsideZone(ZoneId.CASTLE) && _player.getClan() != null && _player.getClan().hasCastle()) + writeD((ing.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100) < 1 ? 1 : ing.getItemCount() * 80 / 100); + else + writeD(ing.getItemCount()); + writeH(ing.getEnchantLevel()); writeD(0x00); // TODO: i.getAugmentId() writeD(0x00); // TODO: i.getManaLeft()  
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt
    • WTB EXP ETERNAL 10x new dm.
    • This project is based on the latest public aCis sources (revision 401) and supports a multi-client system (C4 & IL), making it suitable for custom usage but not for retail.   You can configure the SelectedClient option in server.properties and loginserver.properties to switch between C4 and IL.  Both clients are fully synchronized, including login, server selection, packets, and geodata.   Notable Features: - Completed the login and server selection phase for both clients. - Synchronized all packets to support both clients (including some specific features). - Reworked the datapack and SQL files (excluding HTML files) to work seamlessly with both clients. - Added geodata support for both clients. - Adapted nearly all AI, scripts, bosses, HTML, and MULTISELL files to match C4 functionality. - Reduced the maximum clan level from 8 to 5 (C4 feature). - Rewrote clan HTML to remove C5-C6 features.   Disabled the following C5 and C6 features: - Divine Inspiration (C6 feature). - Clan skills and clan reputation points (C5 feature). - Pledge class (C5 feature). - Hero skills (C5 feature). - Dueling system (C6 feature). - Augmentations (C6 feature). - Cursed weapons (C5-C6 feature).   General Improvements: - Performed a general HTML cleanup and optimized features based on the client version. - Added an option to display the remaining time of disabled skills. - Skill timestamps now update when using the skill list.   This flexibility allows you to create a unique progression system tailored to your needs. The price for the diff patch, which can be applied to aCis public sources, is €150. For inquiries, please contact me via PM or Discord (ID: @Luminous).
  • Topics

×
×
  • Create New...