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

@@ -0,0 +1,6 @@
# ---------------------------------------------------------------------------
# Merchant Zero Sell Price
# ---------------------------------------------------------------------------
# All items sold to merchants reward no Adena.
MerchantZeroSellPrice = False

View File

@@ -120,6 +120,7 @@ public class Config
private static final String CUSTOM_FAKE_PLAYERS_CONFIG_FILE = "./config/Custom/FakePlayers.ini";
private static final String CUSTOM_FIND_PVP_CONFIG_FILE = "./config/Custom/FindPvP.ini";
private static final String CUSTOM_HELLBOUND_STATUS_CONFIG_FILE = "./config/Custom/HellboundStatus.ini";
private static final String CUSTOM_MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE = "./config/Custom/MerchantZeroSellPrice.ini";
private static final String CUSTOM_MULTILANGUAL_SUPPORT_CONFIG_FILE = "./config/Custom/MultilingualSupport.ini";
private static final String CUSTOM_NPC_STAT_MULTIPLIERS_CONFIG_FILE = "./config/Custom/NpcStatMultipliers.ini";
private static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
@@ -1303,6 +1304,7 @@ public class Config
public static boolean FAKE_PLAYER_CAN_DROP_ITEMS;
public static boolean FAKE_PLAYER_CAN_PICKUP;
public static boolean ENABLE_FIND_PVP;
public static boolean MERCHANT_ZERO_SELL_PRICE;
public static boolean PREMIUM_SYSTEM_ENABLED;
public static float PREMIUM_RATE_XP;
public static float PREMIUM_RATE_SP;
@@ -2857,14 +2859,16 @@ public class Config
// Load FindPvP config file (if exists)
final PropertiesParser FindPvP = new PropertiesParser(CUSTOM_FIND_PVP_CONFIG_FILE);
ENABLE_FIND_PVP = FindPvP.getBoolean("EnableFindPvP", false);
// Load HellboundStatus config file (if exists)
final PropertiesParser HellboundStatus = new PropertiesParser(CUSTOM_HELLBOUND_STATUS_CONFIG_FILE);
HELLBOUND_STATUS = HellboundStatus.getBoolean("HellboundStatus", false);
// Load MerchantZeroSellPrice config file (if exists)
final PropertiesParser MerchantZeroSellPrice = new PropertiesParser(CUSTOM_MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE);
MERCHANT_ZERO_SELL_PRICE = MerchantZeroSellPrice.getBoolean("MerchantZeroSellPrice", false);
// Load MultilingualSupport config file (if exists)
final PropertiesParser MultilingualSupport = new PropertiesParser(CUSTOM_MULTILANGUAL_SUPPORT_CONFIG_FILE);

View File

@@ -158,7 +158,7 @@ public class RequestRefundItem implements IClientIncomingPacket
final long count = item.getCount();
weight += count * template.getWeight();
adena += (count * template.getReferencePrice()) / 2;
adena += count * (template.getReferencePrice() / 2);
if (!template.isStackable())
{
slots += count;
@@ -183,7 +183,7 @@ public class RequestRefundItem implements IClientIncomingPacket
return;
}
if ((adena < 0) || !player.reduceAdena("Refund", adena, player.getLastFolkNPC(), false))
if (!Config.MERCHANT_ZERO_SELL_PRICE && ((adena < 0) || !player.reduceAdena("Refund", adena, player.getLastFolkNPC(), false)))
{
client.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
client.sendPacket(ActionFailed.STATIC_PACKET);

View File

@@ -146,7 +146,7 @@ public class RequestSellItem implements IClientIncomingPacket
// Proceed the sell
for (UniqueItemHolder i : _items)
{
ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount(), "sell");
final ItemInstance item = player.checkItemManipulation(i.getObjectId(), i.getCount(), "sell");
if ((item == null) || (!item.isSellable()))
{
continue;
@@ -162,14 +162,18 @@ public class RequestSellItem implements IClientIncomingPacket
if (Config.ALLOW_REFUND)
{
item = player.getInventory().transferItem("Sell", i.getObjectId(), i.getCount(), player.getRefund(), player, merchant);
player.getInventory().transferItem("Sell", i.getObjectId(), i.getCount(), player.getRefund(), player, merchant);
}
else
{
item = player.getInventory().destroyItem("Sell", i.getObjectId(), i.getCount(), player, merchant);
player.getInventory().destroyItem("Sell", i.getObjectId(), i.getCount(), player, merchant);
}
}
player.addAdena("Sell", totalPrice, merchant, false);
if (!Config.MERCHANT_ZERO_SELL_PRICE)
{
player.addAdena("Sell", totalPrice, merchant, false);
}
// Update current load as well
final StatusUpdate su = new StatusUpdate(player);

View File

@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -28,7 +29,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
*/
public class ExBuySellList extends AbstractItemPacket
{
private Collection<ItemInstance> _sellList = null;
private final Collection<ItemInstance> _sellList;
private Collection<ItemInstance> _refundList = null;
private final boolean _done;
@@ -54,7 +55,7 @@ public class ExBuySellList extends AbstractItemPacket
for (ItemInstance item : _sellList)
{
writeItem(packet, item);
packet.writeQ(item.getItem().getReferencePrice() / 2);
packet.writeQ(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : item.getItem().getReferencePrice() / 2);
}
}
else
@@ -62,7 +63,7 @@ public class ExBuySellList extends AbstractItemPacket
packet.writeH(0x00);
}
if ((_refundList != null) && (!_refundList.isEmpty()))
if ((_refundList != null) && !_refundList.isEmpty())
{
packet.writeH(_refundList.size());
int i = 0;
@@ -70,7 +71,7 @@ public class ExBuySellList extends AbstractItemPacket
{
writeItem(packet, item);
packet.writeD(i++);
packet.writeQ((item.getItem().getReferencePrice() / 2) * item.getCount());
packet.writeQ(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : (item.getItem().getReferencePrice() / 2) * item.getCount());
}
}
else