Adapted sellbuffs command for HighFive.
This commit is contained in:
@@ -121,6 +121,7 @@ public final class Config
|
||||
public static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./Config/Custom/PvpAnnounce.ini";
|
||||
public static final String CUSTOM_RANDOM_SPAWNS_CONFIG_FILE = "./Config/Custom/RandomSpawns.ini";
|
||||
public static final String CUSTOM_SCREEN_WELCOME_MESSAGE_CONFIG_FILE = "./Config/Custom/ScreenWelcomeMessage.ini";
|
||||
public static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini";
|
||||
public static final String CUSTOM_SERVER_TIME_CONFIG_FILE = "./Config/Custom/ServerTime.ini";
|
||||
public static final String CUSTOM_STARTING_LOCATION_CONFIG_FILE = "./Config/Custom/StartingLocation.ini";
|
||||
public static final String CUSTOM_TVT_CONFIG_FILE = "./Config/Custom/TeamVersusTeam.ini";
|
||||
@@ -1197,6 +1198,7 @@ public final class Config
|
||||
public static int COMMUNITY_PREMIUM_PRICE_PER_DAY;
|
||||
public static List<Integer> COMMUNITY_AVAILABLE_BUFFS;
|
||||
public static Map<String, Location> COMMUNITY_AVAILABLE_TELEPORTS;
|
||||
public static boolean ENABLE_FIND_PVP;
|
||||
public static boolean PREMIUM_SYSTEM_ENABLED;
|
||||
public static float PREMIUM_RATE_XP;
|
||||
public static float PREMIUM_RATE_SP;
|
||||
@@ -1207,7 +1209,12 @@ public final class Config
|
||||
public static float PREMIUM_RATE_SPOIL_AMOUNT;
|
||||
public static Map<Integer, Float> PREMIUM_RATE_DROP_CHANCE_BY_ID;
|
||||
public static Map<Integer, Float> PREMIUM_RATE_DROP_AMOUNT_BY_ID;
|
||||
public static boolean ENABLE_FIND_PVP;
|
||||
public static boolean SELLBUFF_ENABLED;
|
||||
public static int SELLBUFF_MP_MULTIPLER;
|
||||
public static int SELLBUFF_PAYMENT_ID;
|
||||
public static long SELLBUFF_MIN_PRICE;
|
||||
public static long SELLBUFF_MAX_PRICE;
|
||||
public static int SELLBUFF_MAX_BUFFS;
|
||||
|
||||
/**
|
||||
* This class initializes all global variables for configuration.<br>
|
||||
@@ -2727,6 +2734,16 @@ public final class Config
|
||||
WELCOME_MESSAGE_TEXT = ScreenWelcomeMessage.getString("ScreenWelcomeMessageText", "Welcome to our server!");
|
||||
WELCOME_MESSAGE_TIME = ScreenWelcomeMessage.getInt("ScreenWelcomeMessageTime", 10) * 1000;
|
||||
|
||||
// Load SellBuffs config file (if exists)
|
||||
final PropertiesParser SellBuffs = new PropertiesParser(CUSTOM_SELL_BUFFS_CONFIG_FILE);
|
||||
|
||||
SELLBUFF_ENABLED = SellBuffs.getBoolean("SellBuffEnable", false);
|
||||
SELLBUFF_MP_MULTIPLER = SellBuffs.getInt("MpCostMultipler", 1);
|
||||
SELLBUFF_PAYMENT_ID = SellBuffs.getInt("PaymentID", 57);
|
||||
SELLBUFF_MIN_PRICE = SellBuffs.getLong("MinimalPrice", 100000);
|
||||
SELLBUFF_MAX_PRICE = SellBuffs.getLong("MaximalPrice", 100000000);
|
||||
SELLBUFF_MAX_BUFFS = SellBuffs.getInt("MaxBuffs", 15);
|
||||
|
||||
// Load ServerTime config file (if exists)
|
||||
final PropertiesParser ServerTime = new PropertiesParser(CUSTOM_SERVER_TIME_CONFIG_FILE);
|
||||
|
||||
|
@@ -59,7 +59,6 @@ import com.l2jmobius.gameserver.data.xml.impl.HennaData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.HitConditionBonusData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.KarmaData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
@@ -68,6 +67,7 @@ import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PlayerTemplateData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PlayerXpPercentLostData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SecondaryAuthData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SiegeScheduleData;
|
||||
@@ -116,6 +116,7 @@ import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.RaidBossPointsManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SellBuffsManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ServerRestartManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SoDManager;
|
||||
@@ -281,6 +282,10 @@ public final class GameServer
|
||||
CursedWeaponsManager.getInstance();
|
||||
TransformData.getInstance();
|
||||
BotReportTable.getInstance();
|
||||
if (Config.SELLBUFF_ENABLED)
|
||||
{
|
||||
SellBuffsManager.getInstance();
|
||||
}
|
||||
|
||||
printSection("Scripts");
|
||||
QuestManager.getInstance();
|
||||
|
@@ -32,6 +32,7 @@ import com.l2jmobius.gameserver.model.L2ManufactureItem;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.network.Disconnection;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
|
||||
@@ -73,7 +74,7 @@ public class OfflineTradersTable
|
||||
{
|
||||
stm3.setInt(1, pc.getObjectId()); // Char Id
|
||||
stm3.setLong(2, pc.getOfflineStartTime());
|
||||
stm3.setInt(3, pc.getPrivateStoreType().getId()); // store type
|
||||
stm3.setInt(3, pc.isSellingBuffs() ? PrivateStoreType.SELL_BUFFS.getId() : pc.getPrivateStoreType().getId()); // store type
|
||||
String title = null;
|
||||
|
||||
switch (pc.getPrivateStoreType())
|
||||
@@ -104,14 +105,29 @@ public class OfflineTradersTable
|
||||
continue;
|
||||
}
|
||||
title = pc.getSellList().getTitle();
|
||||
for (TradeItem i : pc.getSellList().getItems())
|
||||
if (pc.isSellingBuffs())
|
||||
{
|
||||
stm_items.setInt(1, pc.getObjectId());
|
||||
stm_items.setInt(2, i.getObjectId());
|
||||
stm_items.setLong(3, i.getCount());
|
||||
stm_items.setLong(4, i.getPrice());
|
||||
stm_items.executeUpdate();
|
||||
stm_items.clearParameters();
|
||||
for (SellBuffHolder holder : pc.getSellingBuffs())
|
||||
{
|
||||
stm_items.setInt(1, pc.getObjectId());
|
||||
stm_items.setInt(2, holder.getSkillId());
|
||||
stm_items.setLong(3, 0);
|
||||
stm_items.setLong(4, holder.getPrice());
|
||||
stm_items.executeUpdate();
|
||||
stm_items.clearParameters();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TradeItem i : pc.getSellList().getItems())
|
||||
{
|
||||
stm_items.setInt(1, pc.getObjectId());
|
||||
stm_items.setInt(2, i.getObjectId());
|
||||
stm_items.setLong(3, i.getCount());
|
||||
stm_items.setLong(4, i.getPrice());
|
||||
stm_items.executeUpdate();
|
||||
stm_items.clearParameters();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -175,7 +191,16 @@ public class OfflineTradersTable
|
||||
}
|
||||
}
|
||||
|
||||
final PrivateStoreType type = PrivateStoreType.findById(rs.getInt("type"));
|
||||
final int typeId = rs.getInt("type");
|
||||
boolean isSellBuff = false;
|
||||
|
||||
if (typeId == PrivateStoreType.SELL_BUFFS.getId())
|
||||
{
|
||||
isSellBuff = true;
|
||||
}
|
||||
|
||||
final PrivateStoreType type = isSellBuff ? PrivateStoreType.PACKAGE_SELL : PrivateStoreType.findById(typeId);
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": PrivateStoreType with id " + rs.getInt("type") + " could not be found.");
|
||||
@@ -199,6 +224,12 @@ public class OfflineTradersTable
|
||||
client.setAccountName(player.getAccountNamePlayer());
|
||||
player.setClient(client);
|
||||
player.setOfflineStartTime(time);
|
||||
|
||||
if (isSellBuff)
|
||||
{
|
||||
player.setIsSellingBuffs(true);
|
||||
}
|
||||
|
||||
player.spawnMe(player.getX(), player.getY(), player.getZ());
|
||||
LoginServerThread.getInstance().addGameServerLogin(player.getAccountName(), client);
|
||||
try (PreparedStatement stm_items = con.prepareStatement(LOAD_OFFLINE_ITEMS))
|
||||
@@ -224,12 +255,22 @@ public class OfflineTradersTable
|
||||
case SELL:
|
||||
case PACKAGE_SELL:
|
||||
{
|
||||
while (items.next())
|
||||
if (player.isSellingBuffs())
|
||||
{
|
||||
if (player.getSellList().addItem(items.getInt(2), items.getLong(3), items.getLong(4)) == null)
|
||||
while (items.next())
|
||||
{
|
||||
continue;
|
||||
// throw new NullPointerException();
|
||||
player.getSellingBuffs().add(new SellBuffHolder(items.getInt("item"), items.getLong("price")));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (items.next())
|
||||
{
|
||||
if (player.getSellList().addItem(items.getInt(2), items.getLong(3), items.getLong(4)) == null)
|
||||
{
|
||||
continue;
|
||||
// throw new NullPointerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
player.getSellList().setTitle(rs.getString("title"));
|
||||
@@ -339,14 +380,29 @@ public class OfflineTradersTable
|
||||
{
|
||||
title = trader.getSellList().getTitle();
|
||||
}
|
||||
for (TradeItem i : trader.getSellList().getItems())
|
||||
if (trader.isSellingBuffs())
|
||||
{
|
||||
stm3.setInt(1, trader.getObjectId());
|
||||
stm3.setInt(2, i.getObjectId());
|
||||
stm3.setLong(3, i.getCount());
|
||||
stm3.setLong(4, i.getPrice());
|
||||
stm3.executeUpdate();
|
||||
stm3.clearParameters();
|
||||
for (SellBuffHolder holder : trader.getSellingBuffs())
|
||||
{
|
||||
stm3.setInt(1, trader.getObjectId());
|
||||
stm3.setInt(2, holder.getSkillId());
|
||||
stm3.setLong(3, 0);
|
||||
stm3.setLong(4, holder.getPrice());
|
||||
stm3.executeUpdate();
|
||||
stm3.clearParameters();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TradeItem i : trader.getSellList().getItems())
|
||||
{
|
||||
stm3.setInt(1, trader.getObjectId());
|
||||
stm3.setInt(2, i.getObjectId());
|
||||
stm3.setLong(3, i.getCount());
|
||||
stm3.setLong(4, i.getPrice());
|
||||
stm3.executeUpdate();
|
||||
stm3.clearParameters();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -373,7 +429,7 @@ public class OfflineTradersTable
|
||||
{
|
||||
stm4.setInt(1, trader.getObjectId()); // Char Id
|
||||
stm4.setLong(2, trader.getOfflineStartTime());
|
||||
stm4.setInt(3, trader.getPrivateStoreType().getId()); // store type
|
||||
stm4.setInt(3, trader.isSellingBuffs() ? PrivateStoreType.SELL_BUFFS.getId() : trader.getPrivateStoreType().getId()); // store type
|
||||
stm4.setString(4, title);
|
||||
stm4.executeUpdate();
|
||||
stm4.clearParameters();
|
||||
|
@@ -27,7 +27,8 @@ public enum PrivateStoreType
|
||||
BUY(3),
|
||||
BUY_MANAGE(4),
|
||||
MANUFACTURE(5),
|
||||
PACKAGE_SELL(8);
|
||||
PACKAGE_SELL(8),
|
||||
SELL_BUFFS(9);
|
||||
|
||||
private int _id;
|
||||
|
||||
|
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.IGameXmlReader;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg;
|
||||
import com.l2jmobius.gameserver.util.HtmlUtil;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Sell Buffs Manager
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class SellBuffsManager implements IGameXmlReader
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName());
|
||||
private static final List<Integer> ALLOWED_BUFFS = new ArrayList<>();
|
||||
private static final String htmlFolder = "data/html/mods/SellBuffs/";
|
||||
|
||||
protected SellBuffsManager()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
if (Config.SELLBUFF_ENABLED)
|
||||
{
|
||||
ALLOWED_BUFFS.clear();
|
||||
parseDatapackFile("data/SellBuffData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + ALLOWED_BUFFS.size() + " allowed buffs.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
final NodeList node = doc.getDocumentElement().getElementsByTagName("skill");
|
||||
for (int i = 0; i < node.getLength(); ++i)
|
||||
{
|
||||
final Element elem = (Element) node.item(i);
|
||||
final int skillId = Integer.parseInt(elem.getAttribute("id"));
|
||||
|
||||
if (!ALLOWED_BUFFS.contains(skillId))
|
||||
{
|
||||
ALLOWED_BUFFS.add(skillId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSellMenu(L2PcInstance player)
|
||||
{
|
||||
final String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htmlFolder + (player.isSellingBuffs() ? "BuffMenu_already.html" : "BuffMenu.html"));
|
||||
CommunityBoardHandler.separateAndSend(html, player);
|
||||
}
|
||||
|
||||
public void sendBuffChoiceMenu(L2PcInstance player, int index)
|
||||
{
|
||||
String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htmlFolder + "BuffChoice.html");
|
||||
html = html.replace("%list%", buildSkillMenu(player, index));
|
||||
CommunityBoardHandler.separateAndSend(html, player);
|
||||
}
|
||||
|
||||
public void sendBuffEditMenu(L2PcInstance player)
|
||||
{
|
||||
String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htmlFolder + "BuffChoice.html");
|
||||
html = html.replace("%list%", buildEditMenu(player));
|
||||
CommunityBoardHandler.separateAndSend(html, player);
|
||||
}
|
||||
|
||||
public void sendBuffMenu(L2PcInstance player, L2PcInstance seller, int index)
|
||||
{
|
||||
if (!seller.isSellingBuffs() || seller.getSellingBuffs().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htmlFolder + "BuffBuyMenu.html");
|
||||
html = html.replace("%list%", buildBuffMenu(player, seller, index));
|
||||
CommunityBoardHandler.separateAndSend(html, player);
|
||||
}
|
||||
|
||||
public void startSellBuffs(L2PcInstance player, String title)
|
||||
{
|
||||
player.sitDown();
|
||||
player.setIsSellingBuffs(true);
|
||||
player.setPrivateStoreType(PrivateStoreType.PACKAGE_SELL);
|
||||
player.getSellList().setTitle(title);
|
||||
player.getSellList().setPackaged(true);
|
||||
player.broadcastUserInfo();
|
||||
player.broadcastPacket(new ExPrivateStoreSetWholeMsg(player));
|
||||
sendSellMenu(player);
|
||||
}
|
||||
|
||||
public void stopSellBuffs(L2PcInstance player)
|
||||
{
|
||||
player.setIsSellingBuffs(false);
|
||||
player.setPrivateStoreType(PrivateStoreType.NONE);
|
||||
player.standUp();
|
||||
player.broadcastUserInfo();
|
||||
sendSellMenu(player);
|
||||
}
|
||||
|
||||
private String buildBuffMenu(L2PcInstance player, L2PcInstance seller, int index)
|
||||
{
|
||||
final int ceiling = index + 10;
|
||||
int nextIndex = -1;
|
||||
int previousIndex = -1;
|
||||
int emptyFields = 0;
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<SellBuffHolder> sellList = new ArrayList<>();
|
||||
|
||||
int count = 0;
|
||||
for (SellBuffHolder holder : seller.getSellingBuffs())
|
||||
{
|
||||
count++;
|
||||
if ((count > index) && (count <= ceiling))
|
||||
{
|
||||
sellList.add(holder);
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 10)
|
||||
{
|
||||
if (count > (index + 10))
|
||||
{
|
||||
nextIndex = index + 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 10)
|
||||
{
|
||||
previousIndex = index - 10;
|
||||
}
|
||||
|
||||
emptyFields = ceiling - sellList.size();
|
||||
|
||||
sb.append("<br>");
|
||||
sb.append(HtmlUtil.getMpGauge(250, (long) seller.getCurrentMp(), seller.getMaxMp(), false));
|
||||
sb.append("<br>");
|
||||
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 background=\"L2UI_CH3.refinewnd_back_Pattern\">");
|
||||
sb.append("<tr><td><br><br><br></td></tr>");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"10\"></td>");
|
||||
sb.append("<td> <button action=\"\" value=\"Icon\" width=75 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Icon
|
||||
sb.append("<td> <button action=\"\" value=\"Name\" width=175 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Name
|
||||
sb.append("<td> <button action=\"\" value=\"Level\" width=85 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Leve
|
||||
sb.append("<td> <button action=\"\" value=\"MP Cost\" width=100 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Price
|
||||
sb.append("<td> <button action=\"\" value=\"Price\" width=200 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Price
|
||||
sb.append("<td> <button action=\"\" value=\"Action\" width=100 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Action
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
for (SellBuffHolder holder : sellList)
|
||||
{
|
||||
final Skill skill = seller.getKnownSkill(holder.getSkillId());
|
||||
if (skill == null)
|
||||
{
|
||||
emptyFields++;
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(Config.SELLBUFF_PAYMENT_ID);
|
||||
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("<td align=center><img src=\"" + skill.getIcon() + "\" width=\"32\" height=\"32\"></td>");
|
||||
sb.append("<td align=left>" + skill.getName() + (skill.getLevel() > 100 ? "<font color=\"LEVEL\"> + " + (skill.getLevel() % 100) + "</font></td>" : "</td>"));
|
||||
sb.append("<td align=center>" + ((skill.getLevel() > 100) ? SkillData.getInstance().getMaxLevel(skill.getId()) : skill.getLevel()) + "</td>");
|
||||
sb.append("<td align=center> <font color=\"1E90FF\">" + (skill.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER) + "</font></td>");
|
||||
sb.append("<td align=center> " + Util.formatAdena(holder.getPrice()) + " <font color=\"LEVEL\"> " + (item != null ? item.getName() : "") + "</font> </td>");
|
||||
sb.append("<td align=center fixwidth=\"50\"><button value=\"Buy Buff\" action=\"bypass -h sellbuffbuyskill " + seller.getObjectId() + " " + skill.getId() + " " + index + "\" width=\"85\" height=\"26\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("<tr><td><br><br></td></tr>");
|
||||
}
|
||||
|
||||
for (int i = 0; i < emptyFields; i++)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("<td align=center></td>");
|
||||
sb.append("<td align=left></td>");
|
||||
sb.append("<td align=center></td>");
|
||||
sb.append("<td align=center></font></td>");
|
||||
sb.append("<td align=center></td>");
|
||||
sb.append("<td align=center fixwidth=\"50\"></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("<tr><td><br><br></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table>");
|
||||
|
||||
sb.append("<table width=\"250\" border=\"0\">");
|
||||
sb.append("<tr>");
|
||||
|
||||
if (previousIndex > -1)
|
||||
{
|
||||
sb.append("<td align=left><button value=\"Previous Page\" action=\"bypass -h sellbuffbuymenu " + seller.getObjectId() + " " + previousIndex + "\" width=\"100\" height=\"30\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
|
||||
if (nextIndex > -1)
|
||||
{
|
||||
sb.append("<td align=right><button value=\"Next Page\" action=\"bypass -h sellbuffbuymenu " + seller.getObjectId() + " " + nextIndex + "\" width=\"100\" height=\"30\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
sb.append("</tr>");
|
||||
sb.append("</table>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String buildEditMenu(L2PcInstance player)
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 background=\"L2UI_CH3.refinewnd_back_Pattern\">");
|
||||
sb.append("<tr><td><br><br><br></td></tr>");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"10\"></td>");
|
||||
sb.append("<td> <button action=\"\" value=\"Icon\" width=75 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Icon
|
||||
sb.append("<td> <button action=\"\" value=\"Name\" width=150 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Name
|
||||
sb.append("<td> <button action=\"\" value=\"Level\" width=75 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Level
|
||||
sb.append("<td> <button action=\"\" value=\"Old Price\" width=100 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Old price
|
||||
sb.append("<td> <button action=\"\" value=\"New Price\" width=125 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // New price
|
||||
sb.append("<td> <button action=\"\" value=\"Action\" width=125 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Change Price
|
||||
sb.append("<td> <button action=\"\" value=\"Remove\" width=85 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Remove Buff
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
if (player.getSellingBuffs().isEmpty())
|
||||
{
|
||||
sb.append("</table>");
|
||||
sb.append("<br><br><br>");
|
||||
sb.append("You don't have added any buffs yet!");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (SellBuffHolder holder : player.getSellingBuffs())
|
||||
{
|
||||
final Skill skill = player.getKnownSkill(holder.getSkillId());
|
||||
if (skill == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("<td align=center><img src=\"" + skill.getIcon() + "\" width=\"32\" height=\"32\"></td>"); // Icon
|
||||
sb.append("<td align=left>" + skill.getName() + (skill.getLevel() > 100 ? "<font color=\"LEVEL\"> + " + (skill.getLevel() % 100) + "</font></td>" : "</td>")); // Name + enchant
|
||||
sb.append("<td align=center>" + ((skill.getLevel() > 100) ? SkillData.getInstance().getMaxLevel(skill.getId()) : skill.getLevel()) + "</td>"); // Level
|
||||
sb.append("<td align=center> " + Util.formatAdena(holder.getPrice()) + " </td>"); // Price show
|
||||
sb.append("<td align=center><edit var=\"price_" + skill.getId() + "\" width=120 type=\"number\"></td>"); // Price edit
|
||||
sb.append("<td align=center><button value=\"Edit\" action=\"bypass -h sellbuffchangeprice " + skill.getId() + " $price_" + skill.getId() + "\" width=\"85\" height=\"26\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
sb.append("<td align=center><button value=\" X \" action=\"bypass -h sellbuffremove " + skill.getId() + "\" width=\"26\" height=\"26\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("<tr><td><br><br></td></tr>");
|
||||
}
|
||||
sb.append("</table>");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String buildSkillMenu(L2PcInstance player, int index)
|
||||
{
|
||||
final int ceiling = index + 10;
|
||||
int nextIndex = -1;
|
||||
int previousIndex = -1;
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<Skill> skillList = new ArrayList<>();
|
||||
|
||||
int count = 0;
|
||||
for (Skill skill : player.getAllSkills())
|
||||
{
|
||||
if (ALLOWED_BUFFS.contains(skill.getId()) && !isInSellList(player, skill))
|
||||
{
|
||||
count++;
|
||||
|
||||
if ((count > index) && (count <= ceiling))
|
||||
{
|
||||
skillList.add(skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 10)
|
||||
{
|
||||
if (count > (index + 10))
|
||||
{
|
||||
nextIndex = index + 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 10)
|
||||
{
|
||||
previousIndex = index - 10;
|
||||
}
|
||||
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 background=\"L2UI_CH3.refinewnd_back_Pattern\">");
|
||||
sb.append("<tr><td><br><br><br></td></tr>");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"10\"></td>");
|
||||
sb.append("<td> <button action=\"\" value=\"Icon\" width=100 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Icon
|
||||
sb.append("<td> <button action=\"\" value=\"Name\" width=175 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Name
|
||||
sb.append("<td> <button action=\"\" value=\"Level\" width=150 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Leve
|
||||
sb.append("<td> <button action=\"\" value=\"Price\" width=150 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Price
|
||||
sb.append("<td> <button action=\"\" value=\"Action\" width=125 height=23 back=\"L2UI_CT1.OlympiadWnd_DF_Watch_Down\" fore=\"L2UI_CT1.OlympiadWnd_DF_Watch\"> </td>"); // Action
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
if (skillList.isEmpty())
|
||||
{
|
||||
sb.append("</table>");
|
||||
sb.append("<br><br><br>");
|
||||
sb.append("At this moment you cant add any buffs!");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Skill skill : skillList)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"20\"></td>");
|
||||
sb.append("<td align=center><img src=\"" + skill.getIcon() + "\" width=\"32\" height=\"32\"></td>");
|
||||
sb.append("<td align=left>" + skill.getName() + (skill.getLevel() > 100 ? "<font color=\"LEVEL\"> + " + (skill.getLevel() % 100) + "</font></td>" : "</td>"));
|
||||
sb.append("<td align=center>" + ((skill.getLevel() > 100) ? SkillData.getInstance().getMaxLevel(skill.getId()) : skill.getLevel()) + "</td>");
|
||||
sb.append("<td align=center><edit var=\"price_" + skill.getId() + "\" width=120 type=\"number\"></td>");
|
||||
sb.append("<td align=center fixwidth=\"50\"><button value=\"Add Buff\" action=\"bypass -h sellbuffaddskill " + skill.getId() + " $price_" + skill.getId() + "\" width=\"85\" height=\"26\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("<tr><td><br><br></td></tr>");
|
||||
}
|
||||
sb.append("</table>");
|
||||
}
|
||||
|
||||
sb.append("<table width=\"250\" border=\"0\">");
|
||||
sb.append("<tr>");
|
||||
|
||||
if (previousIndex > -1)
|
||||
{
|
||||
sb.append("<td align=left><button value=\"Previous Page\" action=\"bypass -h sellbuffadd " + previousIndex + "\" width=\"100\" height=\"30\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
|
||||
if (nextIndex > -1)
|
||||
{
|
||||
sb.append("<td align=right><button value=\"Next Page\" action=\"bypass -h sellbuffadd " + nextIndex + "\" width=\"100\" height=\"30\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
sb.append("</tr>");
|
||||
sb.append("</table>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean isInSellList(L2PcInstance player, Skill skill)
|
||||
{
|
||||
return player.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skill.getId())).findFirst().orElse(null) != null;
|
||||
}
|
||||
|
||||
public boolean canStartSellBuffs(L2PcInstance player)
|
||||
{
|
||||
if (player.isAlikeDead())
|
||||
{
|
||||
player.sendMessage("You can't sell buffs in fake death!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
player.sendMessage("You can't sell buffs with Olympiad status!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent()) // custom event message
|
||||
{
|
||||
player.sendMessage("You can't sell buffs while registered in an event!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isCursedWeaponEquipped() || (player.getKarma() > 0))
|
||||
{
|
||||
player.sendMessage("You can't sell buffs in Chaotic state!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isInDuel())
|
||||
{
|
||||
player.sendMessage("You can't sell buffs in Duel state!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isFishing())
|
||||
{
|
||||
player.sendMessage("You can't sell buffs while fishing.");
|
||||
return false;
|
||||
}
|
||||
else if (player.isMounted() || player.isFlyingMounted() || player.isFlying())
|
||||
{
|
||||
player.sendMessage("You can't sell buffs in Mounth state!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isTransformed())
|
||||
{
|
||||
player.sendMessage("You can't sell buffs in Transform state!");
|
||||
return false;
|
||||
}
|
||||
else if (player.isInsideZone(ZoneId.NO_STORE) || !player.isInsideZone(ZoneId.PEACE) || player.isJailed())
|
||||
{
|
||||
player.sendMessage("You can't sell buffs here!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of {@code SellBuffsManager}.
|
||||
* @return single instance of {@code SellBuffsManager}
|
||||
*/
|
||||
public static SellBuffsManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final SellBuffsManager _instance = new SellBuffsManager();
|
||||
}
|
||||
}
|
@@ -211,6 +211,7 @@ import com.l2jmobius.gameserver.model.fishing.L2Fishing;
|
||||
import com.l2jmobius.gameserver.model.holders.AdditionalSkillHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillUseHolder;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IEventListener;
|
||||
@@ -930,6 +931,29 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
private boolean _hasCharmOfCourage = false;
|
||||
|
||||
// Selling buffs system
|
||||
private boolean _isSellingBuffs = false;
|
||||
private List<SellBuffHolder> _sellingBuffs = null;
|
||||
|
||||
public boolean isSellingBuffs()
|
||||
{
|
||||
return _isSellingBuffs;
|
||||
}
|
||||
|
||||
public void setIsSellingBuffs(boolean val)
|
||||
{
|
||||
_isSellingBuffs = val;
|
||||
}
|
||||
|
||||
public List<SellBuffHolder> getSellingBuffs()
|
||||
{
|
||||
if (_sellingBuffs == null)
|
||||
{
|
||||
_sellingBuffs = new ArrayList<>();
|
||||
}
|
||||
return _sellingBuffs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new L2PcInstance and add it in the characters table of the database.<br>
|
||||
* <B><U> Actions</U> :</B>
|
||||
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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.l2jmobius.gameserver.model.holders;
|
||||
|
||||
/**
|
||||
* Simple class for storing info for Selling Buffs system.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class SellBuffHolder
|
||||
{
|
||||
private final int _skillId;
|
||||
private long _price;
|
||||
|
||||
public SellBuffHolder(int skillId, long price)
|
||||
{
|
||||
_skillId = skillId;
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public final int getSkillId()
|
||||
{
|
||||
return _skillId;
|
||||
}
|
||||
|
||||
public final void setPrice(int price)
|
||||
{
|
||||
_price = price;
|
||||
}
|
||||
|
||||
public final long getPrice()
|
||||
{
|
||||
return _price;
|
||||
}
|
||||
}
|
@@ -271,7 +271,7 @@ public final class RequestActionUse implements IClientIncomingPacket
|
||||
}
|
||||
case 37: // Dwarven Manufacture
|
||||
{
|
||||
if (activeChar.isAlikeDead())
|
||||
if (activeChar.isAlikeDead() || activeChar.isSellingBuffs())
|
||||
{
|
||||
client.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return;
|
||||
|
@@ -91,6 +91,11 @@ public final class RequestExEnchantSkill implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isSellingBuffs())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill skill = SkillData.getInstance().getSkill(_skillId, _skillLvl);
|
||||
if (skill == null)
|
||||
{
|
||||
|
@@ -17,38 +17,43 @@
|
||||
package com.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.instancemanager.SellBuffsManager;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
public class PrivateStoreListSell extends AbstractItemPacket
|
||||
{
|
||||
private final int _objId;
|
||||
private final long _playerAdena;
|
||||
private final boolean _packageSale;
|
||||
private final TradeItem[] _items;
|
||||
private final L2PcInstance _player;
|
||||
private final L2PcInstance _seller;
|
||||
|
||||
public PrivateStoreListSell(L2PcInstance player, L2PcInstance storePlayer)
|
||||
public PrivateStoreListSell(L2PcInstance player, L2PcInstance seller)
|
||||
{
|
||||
_objId = storePlayer.getObjectId();
|
||||
_playerAdena = player.getAdena();
|
||||
_items = storePlayer.getSellList().getItems();
|
||||
_packageSale = storePlayer.getSellList().isPackaged();
|
||||
_player = player;
|
||||
_seller = seller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.PRIVATE_STORE_SELL_LIST.writeId(packet);
|
||||
packet.writeD(_objId);
|
||||
packet.writeD(_packageSale ? 1 : 0);
|
||||
packet.writeQ(_playerAdena);
|
||||
packet.writeD(_items.length);
|
||||
for (TradeItem item : _items)
|
||||
if (_seller.isSellingBuffs())
|
||||
{
|
||||
writeItem(packet, item);
|
||||
packet.writeQ(item.getPrice());
|
||||
packet.writeQ(item.getItem().getReferencePrice() * 2);
|
||||
SellBuffsManager.getInstance().sendBuffMenu(_player, _seller, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
OutgoingPackets.PRIVATE_STORE_SELL_LIST.writeId(packet);
|
||||
|
||||
packet.writeD(_seller.getObjectId());
|
||||
packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0);
|
||||
packet.writeQ(_player.getAdena());
|
||||
packet.writeD(_seller.getSellList().getItems().length);
|
||||
for (TradeItem item : _seller.getSellList().getItems())
|
||||
{
|
||||
writeItem(packet, item);
|
||||
packet.writeQ(item.getPrice());
|
||||
packet.writeQ(item.getItem().getReferencePrice() * 2);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ public class PrivateStoreMsgSell implements IClientOutgoingPacket
|
||||
public PrivateStoreMsgSell(L2PcInstance player)
|
||||
{
|
||||
_objId = player.getObjectId();
|
||||
if (player.getSellList() != null)
|
||||
if ((player.getSellList() != null) || player.isSellingBuffs())
|
||||
{
|
||||
_storeMsg = player.getSellList().getTitle();
|
||||
}
|
||||
|
Reference in New Issue
Block a user