Addition of merchant zero sell price configuration.

This commit is contained in:
MobiusDevelopment
2020-01-04 02:29:32 +00:00
parent d268e06690
commit 1cdcd2f8b0
104 changed files with 399 additions and 377 deletions

View File

@@ -90,7 +90,8 @@ public class Config
// custom
private static final String AWAY_CONFIG_FILE = "./config/custom/Away.ini";
private static final String BANK_CONFIG_FILE = "./config/custom/Bank.ini";
private static final String EVENT_CHAMPION_CONFIG_FILE = "./config/custom/Champion.ini";
private static final String CHAMPION_CONFIG_FILE = "./config/custom/Champion.ini";
private static final String MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE = "./config/custom/MerchantZeroSellPrice.ini";
private static final String OFFLINE_CONFIG_FILE = "./config/custom/Offline.ini";
private static final String OTHER_CONFIG_FILE = "./config/custom/Other.ini";
private static final String SCHEME_BUFFER_CONFIG_FILE = "./config/custom/SchemeBuffer.ini";
@@ -482,6 +483,8 @@ public class Config
public static int L2JMOD_CHAMPION_REWARD_QTY;
public static String L2JMOD_CHAMP_TITLE;
public static boolean MERCHANT_ZERO_SELL_PRICE;
public static boolean L2JMOD_ALLOW_WEDDING;
public static int L2JMOD_WEDDING_PRICE;
public static boolean L2JMOD_WEDDING_PUNISH_INFIDELITY;
@@ -1854,7 +1857,7 @@ public class Config
try
{
final Properties ChampionSettings = new Properties();
final InputStream is = new FileInputStream(new File(EVENT_CHAMPION_CONFIG_FILE));
final InputStream is = new FileInputStream(new File(CHAMPION_CONFIG_FILE));
ChampionSettings.load(is);
is.close();
@@ -1877,7 +1880,25 @@ public class Config
catch (Exception e)
{
e.printStackTrace();
throw new Error("Failed to Load " + EVENT_CHAMPION_CONFIG_FILE + " File.");
throw new Error("Failed to Load " + CHAMPION_CONFIG_FILE + " File.");
}
}
public static void loadMerchantZeroPriceConfig()
{
try
{
final Properties MerchantZeroSellPrice = new Properties();
final InputStream is = new FileInputStream(new File(MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE));
MerchantZeroSellPrice.load(is);
is.close();
MERCHANT_ZERO_SELL_PRICE = Boolean.parseBoolean(MerchantZeroSellPrice.getProperty("MerchantZeroSellPrice", "false"));
}
catch (Exception e)
{
e.printStackTrace();
throw new Error("Failed to Load " + CHAMPION_CONFIG_FILE + " File.");
}
}
@@ -3838,6 +3859,7 @@ public class Config
// Custom
loadChampionConfig();
loadMerchantZeroPriceConfig();
loadWeddingConfig();
loadREBIRTHConfig();
loadAWAYConfig();

View File

@@ -129,8 +129,6 @@ public class RequestSellItem extends GameClientPacket
for (int i = 0; i < _count; i++)
{
final int objectId = _items[(i * 3) + 0];
@SuppressWarnings("unused")
final int itemId = _items[(i * 3) + 1];
final int count = _items[(i * 3) + 2];
// Check count
@@ -171,12 +169,15 @@ public class RequestSellItem extends GameClientPacket
return;
}
item = player.getInventory().destroyItem("Sell", objectId, count, player, null);
player.getInventory().destroyItem("Sell", objectId, count, player, null);
}
if (!Config.MERCHANT_ZERO_SELL_PRICE)
{
player.addAdena("Sell", (int) totalPrice, merchant, false);
}
player.addAdena("Sell", (int) totalPrice, merchant, false);
final String html = HtmCache.getInstance().getHtm("data/html/" + htmlFolder + "/" + merchant.getNpcId() + "-sold.htm");
if (html != null)
{
final NpcHtmlMessage soldMsg = new NpcHtmlMessage(merchant.getObjectId());

View File

@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.gameserver.model.actor.instance.MerchantInstance;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -29,40 +29,23 @@ import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
public class SellList extends GameServerPacket
{
private final PlayerInstance _player;
private final MerchantInstance _lease;
private final int _money;
private final List<ItemInstance> _selllist = new ArrayList<>();
public SellList(PlayerInstance player)
{
_player = player;
_lease = null;
_money = _player.getAdena();
doLease();
}
public SellList(PlayerInstance player, MerchantInstance lease)
{
_player = player;
_lease = lease;
_money = _player.getAdena();
doLease();
}
private void doLease()
{
if (_lease == null)
for (ItemInstance item : _player.getInventory().getItems())
{
for (ItemInstance item : _player.getInventory().getItems())
if ((item != null) && !item.isEquipped() && // Not equipped
item.getItem().isSellable() && // Item is sellable
(item.getItem().getItemId() != 57) && // Adena is not sellable
((_player.getPet() == null) || // Pet not summoned or
(item.getObjectId() != _player.getPet().getControlItemId()))) // Pet is summoned and not the item that summoned the pet
{
if ((item != null) && !item.isEquipped() && // Not equipped
item.getItem().isSellable() && // Item is sellable
(item.getItem().getItemId() != 57) && // Adena is not sellable
((_player.getPet() == null) || // Pet not summoned or
(item.getObjectId() != _player.getPet().getControlItemId()))) // Pet is summoned and not the item that summoned the pet
{
_selllist.add(item);
}
_selllist.add(item);
}
}
}
@@ -72,7 +55,7 @@ public class SellList extends GameServerPacket
{
writeC(0x10);
writeD(_money);
writeD(_lease == null ? 0x00 : 1000000 + _lease.getTemplate().npcId);
writeD(0x00);
writeH(_selllist.size());
@@ -88,11 +71,7 @@ public class SellList extends GameServerPacket
writeH(item.getEnchantLevel());
writeH(0x00);
writeH(0x00);
if (_lease == null)
{
writeD(item.getItem().getReferencePrice() / 2); // wtf??? there is no conditional part in SellList!! this d should allways be here 0.o! fortunately the lease stuff are never ever use so the if allways exectues
}
writeD(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : item.getItem().getReferencePrice() / 2);
}
}
}