This commit is contained in:
mobius
2015-01-01 20:02:50 +00:00
parent eeae660458
commit a6a3718849
17894 changed files with 2818932 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExShowVariationCancelWindow;
import com.l2jserver.gameserver.network.serverpackets.ExShowVariationMakeWindow;
public class Augment implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Augment"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
try
{
switch (Integer.parseInt(command.substring(8, 9).trim()))
{
case 1:
activeChar.sendPacket(ExShowVariationMakeWindow.STATIC_PACKET);
return true;
case 2:
activeChar.sendPacket(ExShowVariationCancelWindow.STATIC_PACKET);
return true;
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.StringTokenizer;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
public class Buy implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Buy"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2MerchantInstance))
{
return false;
}
try
{
StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
if (st.countTokens() < 1)
{
return false;
}
((L2MerchantInstance) target).showBuyWindow(activeChar, Integer.parseInt(st.nextToken()));
return true;
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class BuyShadowItem implements IBypassHandler
{
private static final String[] COMMANDS =
{
"BuyShadowItem"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2MerchantInstance))
{
return false;
}
final NpcHtmlMessage html = new NpcHtmlMessage(((L2Npc) target).getObjectId());
if (activeChar.getLevel() < 40)
{
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item-lowlevel.htm");
}
else if ((activeChar.getLevel() >= 40) && (activeChar.getLevel() < 46))
{
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_d.htm");
}
else if ((activeChar.getLevel() >= 46) && (activeChar.getLevel() < 52))
{
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_c.htm");
}
else if (activeChar.getLevel() >= 52)
{
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_b.htm");
}
html.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
activeChar.sendPacket(html);
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.events.EventDispatcher;
import com.l2jserver.gameserver.model.events.EventType;
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
public class ChatLink implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Chat"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
int val = 0;
try
{
val = Integer.parseInt(command.substring(5));
}
catch (Exception ioobe)
{
}
final L2Npc npc = (L2Npc) target;
if ((val == 0) && npc.hasListener(EventType.ON_NPC_FIRST_TALK))
{
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
}
else
{
npc.showChatWindow(activeChar, val);
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,178 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.ClanPrivilege;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2ClanHallManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2WarehouseInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
import com.l2jserver.gameserver.network.serverpackets.WareHouseDepositList;
import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
public class ClanWarehouse implements IBypassHandler
{
private static final String[] COMMANDS =
{
"withdrawc",
"withdrawsortedc",
"depositc"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2WarehouseInstance) && !(target instanceof L2ClanHallManagerInstance))
{
return false;
}
if (activeChar.isEnchanting())
{
return false;
}
if (activeChar.getClan() == null)
{
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
return false;
}
if (activeChar.getClan().getLevel() == 0)
{
activeChar.sendPacket(SystemMessageId.ONLY_CLANS_OF_CLAN_LEVEL_1_OR_ABOVE_CAN_USE_A_CLAN_WAREHOUSE);
return false;
}
try
{
if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC
{
if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_CLAN)
{
final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
msg.setFile(activeChar.getHtmlPrefix(), "data/html/mods/WhSortedC.htm");
msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
activeChar.sendPacket(msg);
}
else
{
showWithdrawWindow(activeChar, null, (byte) 0);
}
return true;
}
else if (command.toLowerCase().startsWith(COMMANDS[1])) // WithdrawSortedC
{
final String param[] = command.split(" ");
if (param.length > 2)
{
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.getOrder(param[2]));
}
else if (param.length > 1)
{
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.A2Z);
}
else
{
showWithdrawWindow(activeChar, WarehouseListType.ALL, SortedWareHouseWithdrawalList.A2Z);
}
return true;
}
else if (command.toLowerCase().startsWith(COMMANDS[2])) // DepositC
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
activeChar.setInventoryBlockingStatus(true);
if (Config.DEBUG)
{
_log.fine("Source: L2WarehouseInstance.java; Player: " + activeChar.getName() + "; Command: showDepositWindowClan; Message: Showing items to deposit.");
}
activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN));
return true;
}
return false;
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
private static final void showWithdrawWindow(L2PcInstance player, WarehouseListType itemtype, byte sortorder)
{
player.sendPacket(ActionFailed.STATIC_PACKET);
if (!player.hasClanPrivilege(ClanPrivilege.CL_VIEW_WAREHOUSE))
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
return;
}
player.setActiveWarehouse(player.getClan().getWarehouse());
if (player.getActiveWarehouse().getSize() == 0)
{
player.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
return;
}
for (L2ItemInstance i : player.getActiveWarehouse().getItems())
{
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
{
player.getActiveWarehouse().destroyItem("L2ItemInstance", i, player, null);
}
}
if (itemtype != null)
{
player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN, itemtype, sortorder));
}
else
{
player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
}
if (Config.DEBUG)
{
_log.fine("Source: L2WarehouseInstance.java; Player: " + player.getName() + "; Command: showRetrieveWindowClan; Message: Showing stored items.");
}
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.L2Event;
public class EventEngine implements IBypassHandler
{
private static final String[] COMMANDS =
{
"event_participate",
"event_unregister"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
try
{
if (command.equalsIgnoreCase("event_participate"))
{
L2Event.registerPlayer(activeChar);
return true;
}
else if (command.equalsIgnoreCase("event_unregister"))
{
L2Event.removeAndResetPlayer(activeChar);
return true;
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.PcFreight;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.PackageToList;
import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
/**
* @author UnAfraid
*/
public class Freight implements IBypassHandler
{
private static final String[] COMMANDS =
{
"package_withdraw",
"package_deposit"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
if (command.equalsIgnoreCase(COMMANDS[0]))
{
PcFreight freight = activeChar.getFreight();
if (freight != null)
{
if (freight.getSize() > 0)
{
activeChar.setActiveWarehouse(freight);
for (L2ItemInstance i : activeChar.getActiveWarehouse().getItems())
{
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
{
activeChar.getActiveWarehouse().destroyItem("L2ItemInstance", i, activeChar, null);
}
}
activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.FREIGHT));
}
else
{
activeChar.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
}
}
}
else if (command.equalsIgnoreCase(COMMANDS[1]))
{
if (activeChar.getAccountChars().size() < 1)
{
activeChar.sendPacket(SystemMessageId.THAT_CHARACTER_DOES_NOT_EXIST);
}
else
{
activeChar.sendPacket(new PackageToList(activeChar.getAccountChars()));
}
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,137 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemauction.ItemAuction;
import com.l2jserver.gameserver.model.itemauction.ItemAuctionInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExItemAuctionInfoPacket;
public class ItemAuctionLink implements IBypassHandler
{
private static final SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
private static final String[] COMMANDS =
{
"ItemAuction"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
if (!Config.ALT_ITEM_AUCTION_ENABLED)
{
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_AN_AUCTION_PERIOD);
return true;
}
final ItemAuctionInstance au = ItemAuctionManager.getInstance().getManagerInstance(target.getId());
if (au == null)
{
return false;
}
try
{
StringTokenizer st = new StringTokenizer(command);
st.nextToken(); // bypass "ItemAuction"
if (!st.hasMoreTokens())
{
return false;
}
String cmd = st.nextToken();
if ("show".equalsIgnoreCase(cmd))
{
if (!activeChar.getFloodProtectors().getItemAuction().tryPerformAction("RequestInfoItemAuction"))
{
return false;
}
if (activeChar.isItemAuctionPolling())
{
return false;
}
final ItemAuction currentAuction = au.getCurrentAuction();
final ItemAuction nextAuction = au.getNextAuction();
if (currentAuction == null)
{
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_AN_AUCTION_PERIOD);
if (nextAuction != null)
{
activeChar.sendMessage("The next auction will begin on the " + fmt.format(new Date(nextAuction.getStartingTime())) + ".");
}
return true;
}
activeChar.sendPacket(new ExItemAuctionInfoPacket(false, currentAuction, nextAuction));
}
else if ("cancel".equalsIgnoreCase(cmd))
{
final ItemAuction[] auctions = au.getAuctionsByBidder(activeChar.getObjectId());
boolean returned = false;
for (final ItemAuction auction : auctions)
{
if (auction.cancelBid(activeChar))
{
returned = true;
}
}
if (!returned)
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OFFERINGS_I_OWN_OR_I_MADE_A_BID_FOR);
}
}
else
{
return false;
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class Link implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Link"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
String htmlPath = command.substring(4).trim();
if (htmlPath.isEmpty())
{
_log.warning("Player " + activeChar.getName() + " sent empty link html!");
return false;
}
if (htmlPath.contains(".."))
{
_log.warning("Player " + activeChar.getName() + " sent invalid link html: " + htmlPath);
return false;
}
String filename = "data/html/" + htmlPath;
final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0);
html.setFile(activeChar.getHtmlPrefix(), filename);
html.replace("%objectId%", String.valueOf(target != null ? target.getObjectId() : 0));
activeChar.sendPacket(html);
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,349 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.text.DateFormat;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.games.Lottery;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
public class Loto implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Loto"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
int val = 0;
try
{
val = Integer.parseInt(command.substring(5));
}
catch (IndexOutOfBoundsException ioobe)
{
}
catch (NumberFormatException nfe)
{
}
if (val == 0)
{
// new loto ticket
for (int i = 0; i < 5; i++)
{
activeChar.setLoto(i, 0);
}
}
showLotoWindow(activeChar, (L2Npc) target, val);
return false;
}
/**
* Open a Loto window on client with the text of the L2NpcInstance.<BR>
* <BR>
* <B><U> Actions</U> :</B><BR>
* <BR>
* <li>Get the text of the selected HTML file in function of the npcId and of the page number</li> <li>Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance</li> <li>Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the
* client wait another packet</li><BR>
* @param player The L2PcInstance that talk with the L2NpcInstance
* @param npc L2Npc loto instance
* @param val The number of the page of the L2NpcInstance to display
*/
// 0 - first buy lottery ticket window
// 1-20 - buttons
// 21 - second buy lottery ticket window
// 22 - selected ticket with 5 numbers
// 23 - current lottery jackpot
// 24 - Previous winning numbers/Prize claim
// >24 - check lottery ticket by item object id
public static final void showLotoWindow(L2PcInstance player, L2Npc npc, int val)
{
int npcId = npc.getTemplate().getId();
String filename;
SystemMessage sm;
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
if (val == 0) // 0 - first buy lottery ticket window
{
filename = (npc.getHtmlPath(npcId, 1));
html.setFile(player.getHtmlPrefix(), filename);
}
else if ((val >= 1) && (val <= 21)) // 1-20 - buttons, 21 - second buy lottery ticket window
{
if (!Lottery.getInstance().isStarted())
{
// tickets can't be sold
player.sendPacket(SystemMessageId.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
return;
}
if (!Lottery.getInstance().isSellableTickets())
{
// tickets can't be sold
player.sendPacket(SystemMessageId.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
return;
}
filename = (npc.getHtmlPath(npcId, 5));
html.setFile(player.getHtmlPrefix(), filename);
int count = 0;
int found = 0;
// counting buttons and unsetting button if found
for (int i = 0; i < 5; i++)
{
if (player.getLoto(i) == val)
{
// unsetting button
player.setLoto(i, 0);
found = 1;
}
else if (player.getLoto(i) > 0)
{
count++;
}
}
// if not rearched limit 5 and not unseted value
if ((count < 5) && (found == 0) && (val <= 20))
{
for (int i = 0; i < 5; i++)
{
if (player.getLoto(i) == 0)
{
player.setLoto(i, val);
break;
}
}
}
// setting pusshed buttons
count = 0;
for (int i = 0; i < 5; i++)
{
if (player.getLoto(i) > 0)
{
count++;
String button = String.valueOf(player.getLoto(i));
if (player.getLoto(i) < 10)
{
button = "0" + button;
}
String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
html.replace(search, replace);
}
}
if (count == 5)
{
String search = "0\">Return";
String replace = "22\">Your lucky numbers have been selected above.";
html.replace(search, replace);
}
}
else if (val == 22) // 22 - selected ticket with 5 numbers
{
if (!Lottery.getInstance().isStarted())
{
// tickets can't be sold
player.sendPacket(SystemMessageId.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
return;
}
if (!Lottery.getInstance().isSellableTickets())
{
// tickets can't be sold
player.sendPacket(SystemMessageId.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
return;
}
long price = Config.ALT_LOTTERY_TICKET_PRICE;
int lotonumber = Lottery.getInstance().getId();
int enchant = 0;
int type2 = 0;
for (int i = 0; i < 5; i++)
{
if (player.getLoto(i) == 0)
{
return;
}
if (player.getLoto(i) < 17)
{
enchant += Math.pow(2, player.getLoto(i) - 1);
}
else
{
type2 += Math.pow(2, player.getLoto(i) - 17);
}
}
if (player.getAdena() < price)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
player.sendPacket(sm);
return;
}
if (!player.reduceAdena("Loto", price, npc, true))
{
return;
}
Lottery.getInstance().increasePrize(price);
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
sm.addItemName(4442);
player.sendPacket(sm);
L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4442);
item.setCount(1);
item.setCustomType1(lotonumber);
item.setEnchantLevel(enchant);
item.setCustomType2(type2);
player.getInventory().addItem("Loto", item, player, npc);
InventoryUpdate iu = new InventoryUpdate();
iu.addItem(item);
L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
iu.addModifiedItem(adenaupdate);
player.sendPacket(iu);
filename = (npc.getHtmlPath(npcId, 6));
html.setFile(player.getHtmlPrefix(), filename);
}
else if (val == 23) // 23 - current lottery jackpot
{
filename = (npc.getHtmlPath(npcId, 3));
html.setFile(player.getHtmlPrefix(), filename);
}
else if (val == 24) // 24 - Previous winning numbers/Prize claim
{
filename = (npc.getHtmlPath(npcId, 4));
html.setFile(player.getHtmlPrefix(), filename);
int lotonumber = Lottery.getInstance().getId();
String message = "";
for (L2ItemInstance item : player.getInventory().getItems())
{
if (item == null)
{
continue;
}
if ((item.getId() == 4442) && (item.getCustomType1() < lotonumber))
{
message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">" + item.getCustomType1() + " Event Number ";
int[] numbers = Lottery.getInstance().decodeNumbers(item.getEnchantLevel(), item.getCustomType2());
for (int i = 0; i < 5; i++)
{
message += numbers[i] + " ";
}
long[] check = Lottery.getInstance().checkTicket(item);
if (check[0] > 0)
{
switch ((int) check[0])
{
case 1:
message += "- 1st Prize";
break;
case 2:
message += "- 2nd Prize";
break;
case 3:
message += "- 3th Prize";
break;
case 4:
message += "- 4th Prize";
break;
}
message += " " + check[1] + "a.";
}
message += "</a><br>";
}
}
if (message.isEmpty())
{
message += "There has been no winning lottery ticket.<br>";
}
html.replace("%result%", message);
}
else if (val == 25) // 25 - lottery instructions
{
filename = (npc.getHtmlPath(npcId, 2));
html.setFile(player.getHtmlPrefix(), filename);
}
else if (val > 25) // >25 - check lottery ticket by item object id
{
int lotonumber = Lottery.getInstance().getId();
L2ItemInstance item = player.getInventory().getItemByObjectId(val);
if ((item == null) || (item.getId() != 4442) || (item.getCustomType1() >= lotonumber))
{
return;
}
long[] check = Lottery.getInstance().checkTicket(item);
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(4442);
player.sendPacket(sm);
long adena = check[1];
if (adena > 0)
{
player.addAdena("Loto", adena, npc, true);
}
player.destroyItem("Loto", item, npc, false);
return;
}
html.replace("%objectId%", String.valueOf(npc.getObjectId()));
html.replace("%race%", "" + Lottery.getInstance().getId());
html.replace("%adena%", "" + Lottery.getInstance().getPrize());
html.replace("%ticket_price%", "" + Config.ALT_LOTTERY_TICKET_PRICE);
html.replace("%prize5%", "" + (Config.ALT_LOTTERY_5_NUMBER_RATE * 100));
html.replace("%prize4%", "" + (Config.ALT_LOTTERY_4_NUMBER_RATE * 100));
html.replace("%prize3%", "" + (Config.ALT_LOTTERY_3_NUMBER_RATE * 100));
html.replace("%prize2%", "" + Config.ALT_LOTTERY_2_AND_1_NUMBER_PRIZE);
html.replace("%enddate%", "" + DateFormat.getDateInstance().format(Lottery.getInstance().getEndDate()));
player.sendPacket(html);
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
player.sendPacket(ActionFailed.STATIC_PACKET);
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.datatables.MultisellData;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
public class Multisell implements IBypassHandler
{
private static final String[] COMMANDS =
{
"multisell",
"exc_multisell"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
try
{
int listId;
if (command.toLowerCase().startsWith(COMMANDS[0])) // multisell
{
listId = Integer.parseInt(command.substring(9).trim());
MultisellData.getInstance().separateAndSend(listId, activeChar, (L2Npc) target, false);
return true;
}
else if (command.toLowerCase().startsWith(COMMANDS[1])) // exc_multisell
{
listId = Integer.parseInt(command.substring(13).trim());
MultisellData.getInstance().separateAndSend(listId, activeChar, (L2Npc) target, true);
return true;
}
return false;
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,436 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.Elementals;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Spawn;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.drops.DropListScope;
import com.l2jserver.gameserver.model.drops.GeneralDropItem;
import com.l2jserver.gameserver.model.drops.GroupedGeneralDropItem;
import com.l2jserver.gameserver.model.drops.IDropItem;
import com.l2jserver.gameserver.model.items.L2Item;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.util.HtmlUtil;
import com.l2jserver.gameserver.util.Util;
/**
* @author NosBit
*/
public class NpcViewMod implements IBypassHandler
{
private static final String[] COMMANDS =
{
"NpcViewMod"
};
private static final int DROP_LIST_ITEMS_PER_PAGE = 10;
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character bypassOrigin)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
if (!st.hasMoreTokens())
{
_log.warning("Bypass[NpcViewMod] used without enough parameters.");
return false;
}
final String actualCommand = st.nextToken();
switch (actualCommand.toLowerCase())
{
case "view":
{
final L2Object target;
if (st.hasMoreElements())
{
try
{
target = L2World.getInstance().findObject(Integer.parseInt(st.nextToken()));
}
catch (NumberFormatException e)
{
return false;
}
}
else
{
target = activeChar.getTarget();
}
final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
if (npc == null)
{
return false;
}
NpcViewMod.sendNpcView(activeChar, npc);
break;
}
case "droplist":
{
if (st.countTokens() < 2)
{
_log.warning("Bypass[NpcViewMod] used without enough parameters.");
return false;
}
final String dropListScopeString = st.nextToken();
try
{
final DropListScope dropListScope = Enum.valueOf(DropListScope.class, dropListScopeString);
final L2Object target = L2World.getInstance().findObject(Integer.parseInt(st.nextToken()));
final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
if (npc == null)
{
return false;
}
final int page = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
sendNpcDropList(activeChar, npc, dropListScope, page);
}
catch (NumberFormatException e)
{
return false;
}
catch (IllegalArgumentException e)
{
_log.warning("Bypass[NpcViewMod] unknown drop list scope: " + dropListScopeString);
return false;
}
break;
}
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
public static void sendNpcView(L2PcInstance activeChar, L2Npc npc)
{
final NpcHtmlMessage html = new NpcHtmlMessage();
html.setFile(activeChar.getHtmlPrefix(), "data/html/mods/NpcView/Info.htm");
html.replace("%name%", npc.getName());
html.replace("%hpGauge%", HtmlUtil.getHpGauge(250, (long) npc.getCurrentHp(), npc.getMaxHp(), false));
html.replace("%mpGauge%", HtmlUtil.getMpGauge(250, (long) npc.getCurrentMp(), npc.getMaxMp(), false));
final L2Spawn npcSpawn = npc.getSpawn();
if ((npcSpawn == null) || (npcSpawn.getRespawnMinDelay() == 0))
{
html.replace("%respawn%", "None");
}
else
{
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
long min = Long.MAX_VALUE;
for (TimeUnit tu : TimeUnit.values())
{
final long minTimeFromMillis = tu.convert(npcSpawn.getRespawnMinDelay(), TimeUnit.MILLISECONDS);
final long maxTimeFromMillis = tu.convert(npcSpawn.getRespawnMaxDelay(), TimeUnit.MILLISECONDS);
if ((TimeUnit.MILLISECONDS.convert(minTimeFromMillis, tu) == npcSpawn.getRespawnMinDelay()) && (TimeUnit.MILLISECONDS.convert(maxTimeFromMillis, tu) == npcSpawn.getRespawnMaxDelay()))
{
if (min > minTimeFromMillis)
{
min = minTimeFromMillis;
timeUnit = tu;
}
}
}
final long minRespawnDelay = timeUnit.convert(npcSpawn.getRespawnMinDelay(), TimeUnit.MILLISECONDS);
final long maxRespawnDelay = timeUnit.convert(npcSpawn.getRespawnMaxDelay(), TimeUnit.MILLISECONDS);
final String timeUnitName = timeUnit.name().charAt(0) + timeUnit.name().toLowerCase().substring(1);
if (npcSpawn.hasRespawnRandom())
{
html.replace("%respawn%", minRespawnDelay + "-" + maxRespawnDelay + " " + timeUnitName);
}
else
{
html.replace("%respawn%", minRespawnDelay + " " + timeUnitName);
}
}
html.replace("%atktype%", Util.capitalizeFirst(npc.getAttackType().name().toLowerCase()));
html.replace("%atkrange%", npc.getStat().getPhysicalAttackRange());
html.replace("%patk%", npc.getPAtk(activeChar));
html.replace("%pdef%", npc.getPDef(activeChar));
html.replace("%matk%", npc.getMAtk(activeChar, null));
html.replace("%mdef%", npc.getMDef(activeChar, null));
html.replace("%atkspd%", npc.getPAtkSpd());
html.replace("%castspd%", npc.getMAtkSpd());
html.replace("%critrate%", npc.getStat().getCriticalHit(activeChar, null));
html.replace("%evasion%", npc.getEvasionRate(activeChar));
html.replace("%accuracy%", npc.getStat().getAccuracy());
html.replace("%speed%", (int) npc.getStat().getMoveSpeed());
html.replace("%attributeatktype%", Elementals.getElementName(npc.getStat().getAttackElement()));
html.replace("%attributeatkvalue%", npc.getStat().getAttackElementValue(npc.getStat().getAttackElement()));
html.replace("%attributefire%", npc.getStat().getDefenseElementValue(Elementals.FIRE));
html.replace("%attributewater%", npc.getStat().getDefenseElementValue(Elementals.WATER));
html.replace("%attributewind%", npc.getStat().getDefenseElementValue(Elementals.WIND));
html.replace("%attributeearth%", npc.getStat().getDefenseElementValue(Elementals.EARTH));
html.replace("%attributedark%", npc.getStat().getDefenseElementValue(Elementals.DARK));
html.replace("%attributeholy%", npc.getStat().getDefenseElementValue(Elementals.HOLY));
html.replace("%dropListButtons%", getDropListButtons(npc));
activeChar.sendPacket(html);
}
public static String getDropListButtons(L2Npc npc)
{
final StringBuilder sb = new StringBuilder();
final Map<DropListScope, List<IDropItem>> dropLists = npc.getTemplate().getDropLists();
if ((dropLists != null) && !dropLists.isEmpty() && (dropLists.containsKey(DropListScope.DEATH) || dropLists.containsKey(DropListScope.CORPSE)))
{
sb.append("<table width=275 cellpadding=0 cellspacing=0><tr>");
if (dropLists.containsKey(DropListScope.DEATH))
{
sb.append("<td align=center><button value=\"Show Drop\" width=100 height=25 action=\"bypass NpcViewMod dropList DEATH " + npc.getObjectId() + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>");
}
if (dropLists.containsKey(DropListScope.CORPSE))
{
sb.append("<td align=center><button value=\"Show Spoil\" width=100 height=25 action=\"bypass NpcViewMod dropList CORPSE " + npc.getObjectId() + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>");
}
sb.append("</tr></table>");
}
return sb.toString();
}
public static void sendNpcDropList(L2PcInstance activeChar, L2Npc npc, DropListScope dropListScope, int page)
{
final List<IDropItem> dropList = npc.getTemplate().getDropList(dropListScope);
if ((dropList == null) || dropList.isEmpty())
{
return;
}
int pages = dropList.size() / DROP_LIST_ITEMS_PER_PAGE;
if ((DROP_LIST_ITEMS_PER_PAGE * pages) < dropList.size())
{
pages++;
}
final StringBuilder pagesSb = new StringBuilder();
if (pages > 1)
{
pagesSb.append("<table><tr>");
for (int i = 0; i < pages; i++)
{
pagesSb.append("<td align=center><button value=\"" + (i + 1) + "\" width=20 height=20 action=\"bypass NpcViewMod dropList " + dropListScope + " " + npc.getObjectId() + " " + i + "\" back=\"L2UI_CT1.Button_DF_Calculator_Down\" fore=\"L2UI_CT1.Button_DF_Calculator\"></td>");
}
pagesSb.append("</tr></table>");
}
if (page >= pages)
{
page = pages - 1;
}
final int start = page > 0 ? page * DROP_LIST_ITEMS_PER_PAGE : 0;
int end = (page * DROP_LIST_ITEMS_PER_PAGE) + DROP_LIST_ITEMS_PER_PAGE;
if (end > dropList.size())
{
end = dropList.size();
}
final DecimalFormat amountFormat = new DecimalFormat("#,###");
final DecimalFormat chanceFormat = new DecimalFormat("0.00##");
int leftHeight = 0;
int rightHeight = 0;
final StringBuilder leftSb = new StringBuilder();
final StringBuilder rightSb = new StringBuilder();
for (int i = start; i < end; i++)
{
final StringBuilder sb = new StringBuilder();
int height = 64;
final IDropItem dropItem = dropList.get(i);
if (dropItem instanceof GeneralDropItem)
{
final GeneralDropItem generalDropItem = (GeneralDropItem) dropItem;
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
else if (dropItem instanceof GroupedGeneralDropItem)
{
final GroupedGeneralDropItem generalGroupedDropItem = (GroupedGeneralDropItem) dropItem;
if (generalGroupedDropItem.getItems().size() == 1)
{
final GeneralDropItem generalDropItem = generalGroupedDropItem.getItems().get(0);
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalGroupedDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
else
{
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top><img src=\"L2UI_CT1.ICON_DF_premiumItem\" width=32 height=32></td>");
sb.append("<td fixwidth=300 align=center><font name=\"ScreenMessageSmall\" color=\"CD9000\">One from group</font>");
sb.append("</td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0><tr>");
sb.append("<td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalGroupedDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table><br>");
for (GeneralDropItem generalDropItem : generalGroupedDropItem.getItems())
{
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=291 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=259 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=259><table width=253 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td><td width=205 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=205 align=center>");
sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=259>&nbsp;</td></tr></table>");
height += 64;
}
sb.append("</td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
}
if (leftHeight >= (rightHeight + height))
{
rightSb.append(sb);
rightHeight += height;
}
else
{
leftSb.append(sb);
leftHeight += height;
}
}
final StringBuilder bodySb = new StringBuilder();
bodySb.append("<table><tr>");
bodySb.append("<td>");
bodySb.append(leftSb.toString());
bodySb.append("</td><td>");
bodySb.append(rightSb.toString());
bodySb.append("</td>");
bodySb.append("</tr></table>");
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/mods/NpcView/DropList.htm");
if (html == null)
{
_log.warning(NpcViewMod.class.getSimpleName() + ": The html file data/html/mods/NpcView/DropList.htm could not be found.");
return;
}
html = html.replaceAll("%name%", npc.getName());
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
html = html.replaceAll("%pages%", pagesSb.toString());
html = html.replaceAll("%items%", bodySb.toString());
Util.sendCBHtml(activeChar, html);
}
}

View File

@@ -0,0 +1,176 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.instancemanager.SiegeManager;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2ObservationInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
public class Observation implements IBypassHandler
{
private static final String[] COMMANDS =
{
"observesiege",
"observeoracle",
"observe"
};
private static final int[][] LOCATIONS = new int[][]
{
//@formatter:off
// Gludio
{-18347, 114000, -2360, 500},
{-18347, 113255, -2447, 500},
// Dion
{22321, 155785, -2604, 500},
{22321, 156492, -2627, 500},
// Giran
{112000, 144864, -2445, 500},
{112657, 144864, -2525, 500},
// Innadril
{116260, 244600, -775, 500},
{116260, 245264, -721, 500},
// Oren
{78100, 36950, -2242, 500},
{78744, 36950, -2244, 500},
// Aden
{147457, 9601, -233, 500},
{147457, 8720, -252, 500},
// Goddard
{147542, -43543, -1328, 500},
{147465, -45259, -1328, 500},
// Rune
{20598, -49113, -300, 500},
{18702, -49150, -600, 500},
// Schuttgart
{77541, -147447, 353, 500},
{77541, -149245, 353, 500},
// Coliseum
{148416, 46724, -3000, 80},
{149500, 46724, -3000, 80},
{150511, 46724, -3000, 80},
// Dusk
{-77200, 88500, -4800, 500},
{-75320, 87135, -4800, 500},
{-76840, 85770, -4800, 500},
{-76840, 85770, -4800, 500},
{-79950, 85165, -4800, 500},
// Dawn
{-79185, 112725, -4300, 500},
{-76175, 113330, -4300, 500},
{-74305, 111965, -4300, 500},
{-75915, 110600, -4300, 500},
{-78930, 110005, -4300, 500}
//@formatter:on
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2ObservationInstance))
{
return false;
}
if (activeChar.hasSummon())
{
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_OBSERVE_A_SIEGE_WITH_A_PET_OR_SERVITOR_SUMMONED);
return false;
}
if (activeChar.isOnEvent())
{
activeChar.sendMessage("Cannot use while current Event");
return false;
}
String _command = command.split(" ")[0].toLowerCase();
final int param;
try
{
param = Integer.parseInt(command.split(" ")[1]);
}
catch (NumberFormatException nfe)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), nfe);
return false;
}
if ((param < 0) || (param > (LOCATIONS.length - 1)))
{
return false;
}
final int[] locCost = LOCATIONS[param];
Location loc = new Location(locCost[0], locCost[1], locCost[2]);
final long cost = locCost[3];
switch (_command)
{
case "observesiege":
{
if (SiegeManager.getInstance().getSiege(loc) != null)
{
doObserve(activeChar, (L2Npc) target, loc, cost);
}
else
{
activeChar.sendPacket(SystemMessageId.OBSERVATION_IS_ONLY_POSSIBLE_DURING_A_SIEGE);
}
return true;
}
case "observeoracle": // Oracle Dusk/Dawn
{
doObserve(activeChar, (L2Npc) target, loc, cost);
return true;
}
case "observe": // Observe
{
doObserve(activeChar, (L2Npc) target, loc, cost);
return true;
}
}
return false;
}
private static final void doObserve(final L2PcInstance player, final L2Npc npc, final Location pos, final long cost)
{
if (player.reduceAdena("Broadcast", cost, npc, true))
{
// enter mode
player.enterObserverMode(pos);
player.sendPacket(new ItemList(player, false));
}
player.sendPacket(ActionFailed.STATIC_PACKET);
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,376 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.MultisellData;
import com.l2jserver.gameserver.datatables.NpcBufferTable;
import com.l2jserver.gameserver.datatables.NpcBufferTable.NpcBufferData;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Hero;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.olympiad.CompetitionType;
import com.l2jserver.gameserver.model.olympiad.Olympiad;
import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExHeroList;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author DS
*/
public class OlympiadManagerLink implements IBypassHandler
{
private static final String[] COMMANDS =
{
"olympiaddesc",
"olympiadnoble",
"olybuff",
"olympiad"
};
private static final String FEWER_THAN = "Fewer than " + String.valueOf(Config.ALT_OLY_REG_DISPLAY);
private static final String MORE_THAN = "More than " + String.valueOf(Config.ALT_OLY_REG_DISPLAY);
private static final int GATE_PASS = Config.ALT_OLY_COMP_RITEM;
private static final int[] BUFFS =
{
4357, // Haste Lv2
4342, // Wind Walk Lv2
4356, // Empower Lv3
4355, // Acumen Lv3
4351, // Concentration Lv6
4345, // Might Lv3
4358, // Guidance Lv3
4359, // Focus Lv3
4360, // Death Whisper Lv3
4352, // Berserker Spirit Lv2
};
@Override
public final boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2OlympiadManagerInstance))
{
return false;
}
try
{
if (command.toLowerCase().startsWith("olympiaddesc"))
{
int val = Integer.parseInt(command.substring(13, 14));
String suffix = command.substring(14);
((L2OlympiadManagerInstance) target).showChatWindow(activeChar, val, suffix);
}
else if (command.toLowerCase().startsWith("olympiadnoble"))
{
final NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
if (activeChar.isCursedWeaponEquipped())
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_cursed_weapon.htm");
activeChar.sendPacket(html);
return false;
}
if (activeChar.getClassIndex() != 0)
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_sub.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
return false;
}
if (!activeChar.isNoble() || (activeChar.getClassId().level() < 3))
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_thirdclass.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
return false;
}
int passes;
int val = Integer.parseInt(command.substring(14));
switch (val)
{
case 0: // H5 match selection
if (!OlympiadManager.getInstance().isRegistered(activeChar))
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_desc2a.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
html.replace("%olympiad_period%", String.valueOf(Olympiad.getInstance().getPeriod()));
html.replace("%olympiad_cycle%", String.valueOf(Olympiad.getInstance().getCurrentCycle()));
html.replace("%olympiad_opponent%", String.valueOf(OlympiadManager.getInstance().getCountOpponents()));
activeChar.sendPacket(html);
}
else
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_unregister.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
}
break;
case 1: // unregister
OlympiadManager.getInstance().unRegisterNoble(activeChar);
break;
case 2: // show waiting list | TODO: cleanup (not used anymore)
final int nonClassed = OlympiadManager.getInstance().getRegisteredNonClassBased().size();
final int teams = OlympiadManager.getInstance().getRegisteredTeamsBased().size();
final Collection<List<Integer>> allClassed = OlympiadManager.getInstance().getRegisteredClassBased().values();
int classed = 0;
if (!allClassed.isEmpty())
{
for (List<Integer> cls : allClassed)
{
if (cls != null)
{
classed += cls.size();
}
}
}
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_registered.htm");
if (Config.ALT_OLY_REG_DISPLAY > 0)
{
html.replace("%listClassed%", classed < Config.ALT_OLY_REG_DISPLAY ? FEWER_THAN : MORE_THAN);
html.replace("%listNonClassedTeam%", teams < Config.ALT_OLY_REG_DISPLAY ? FEWER_THAN : MORE_THAN);
html.replace("%listNonClassed%", nonClassed < Config.ALT_OLY_REG_DISPLAY ? FEWER_THAN : MORE_THAN);
}
else
{
html.replace("%listClassed%", String.valueOf(classed));
html.replace("%listNonClassedTeam%", String.valueOf(teams));
html.replace("%listNonClassed%", String.valueOf(nonClassed));
}
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
break;
case 3: // There are %points% Grand Olympiad points granted for this event. | TODO: cleanup (not used anymore)
int points = Olympiad.getInstance().getNoblePoints(activeChar.getObjectId());
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_points1.htm");
html.replace("%points%", String.valueOf(points));
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
break;
case 4: // register non classed
OlympiadManager.getInstance().registerNoble(activeChar, CompetitionType.NON_CLASSED);
break;
case 5: // register classed
OlympiadManager.getInstance().registerNoble(activeChar, CompetitionType.CLASSED);
break;
case 6: // request tokens reward
passes = Olympiad.getInstance().getNoblessePasses(activeChar, false);
if (passes > 0)
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_settle.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
}
else
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_nopoints2.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
}
break;
case 7: // Equipment Rewards
MultisellData.getInstance().separateAndSend(102, activeChar, (L2Npc) target, false);
break;
case 8: // Misc. Rewards
MultisellData.getInstance().separateAndSend(103, activeChar, (L2Npc) target, false);
break;
case 9: // Your Grand Olympiad Score from the previous period is %points% point(s) | TODO: cleanup (not used anymore)
int point = Olympiad.getInstance().getLastNobleOlympiadPoints(activeChar.getObjectId());
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "noble_points2.htm");
html.replace("%points%", String.valueOf(point));
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
break;
case 10: // give tokens to player
passes = Olympiad.getInstance().getNoblessePasses(activeChar, true);
if (passes > 0)
{
L2ItemInstance item = activeChar.getInventory().addItem("Olympiad", GATE_PASS, passes, activeChar, target);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
activeChar.sendPacket(iu);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
sm.addLong(passes);
sm.addItemName(item);
activeChar.sendPacket(sm);
}
break;
case 11: // register team
OlympiadManager.getInstance().registerNoble(activeChar, CompetitionType.TEAMS);
break;
default:
_log.warning("Olympiad System: Couldnt send packet for request " + val);
break;
}
}
else if (command.toLowerCase().startsWith("olybuff"))
{
int buffCount = activeChar.getOlympiadBuffCount();
if (buffCount <= 0)
{
return false;
}
final NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
String[] params = command.split(" ");
if (!Util.isDigit(params[1]))
{
_log.warning("Olympiad Buffer Warning: npcId = " + target.getId() + " has invalid buffGroup set in the bypass for the buff selected: " + params[1]);
return false;
}
final int index = Integer.parseInt(params[1]);
if ((index < 0) || (index > BUFFS.length))
{
_log.warning("Olympiad Buffer Warning: npcId = " + target.getId() + " has invalid index sent in the bypass: " + index);
return false;
}
final NpcBufferData npcBuffGroupInfo = NpcBufferTable.getInstance().getSkillInfo(target.getId(), BUFFS[index]);
if (npcBuffGroupInfo == null)
{
_log.warning("Olympiad Buffer Warning: npcId = " + target.getId() + " Location: " + target.getX() + ", " + target.getY() + ", " + target.getZ() + " Player: " + activeChar.getName() + " has tried to use skill group (" + params[1] + ") not assigned to the NPC Buffer!");
return false;
}
if (buffCount > 0)
{
final Skill skill = npcBuffGroupInfo.getSkill().getSkill();
if (skill != null)
{
target.setTarget(activeChar);
activeChar.setOlympiadBuffCount(--buffCount);
target.broadcastPacket(new MagicSkillUse(target, activeChar, skill.getId(), skill.getLevel(), 0, 0));
skill.applyEffects(activeChar, activeChar);
final L2Summon summon = activeChar.getSummon();
if (summon != null)
{
target.broadcastPacket(new MagicSkillUse(target, summon, skill.getId(), skill.getLevel(), 0, 0));
skill.applyEffects(summon, summon);
}
}
}
if (buffCount > 0)
{
html.setFile(activeChar.getHtmlPrefix(), buffCount == Config.ALT_OLY_MAX_BUFFS ? Olympiad.OLYMPIAD_HTML_PATH + "olympiad_buffs.htm" : Olympiad.OLYMPIAD_HTML_PATH + "olympiad_5buffs.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
}
else
{
html.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "olympiad_nobuffs.htm");
html.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(html);
target.decayMe();
}
}
else if (command.toLowerCase().startsWith("olympiad"))
{
int val = Integer.parseInt(command.substring(9, 10));
final NpcHtmlMessage reply = new NpcHtmlMessage(target.getObjectId());
switch (val)
{
case 2: // show rank for a specific class
// for example >> Olympiad 1_88
int classId = Integer.parseInt(command.substring(11));
if (((classId >= 88) && (classId <= 118)) || ((classId >= 131) && (classId <= 134)) || (classId == 136))
{
List<String> names = Olympiad.getInstance().getClassLeaderBoard(classId);
reply.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "olympiad_ranking.htm");
int index = 1;
for (String name : names)
{
reply.replace("%place" + index + "%", String.valueOf(index));
reply.replace("%rank" + index + "%", name);
index++;
if (index > 10)
{
break;
}
}
for (; index <= 10; index++)
{
reply.replace("%place" + index + "%", "");
reply.replace("%rank" + index + "%", "");
}
reply.replace("%objectId%", String.valueOf(target.getObjectId()));
activeChar.sendPacket(reply);
}
break;
case 4: // hero list
activeChar.sendPacket(new ExHeroList());
break;
case 5: // Hero Certification
if (Hero.getInstance().isUnclaimedHero(activeChar.getObjectId()))
{
Hero.getInstance().claimHero(activeChar);
reply.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "hero_receive.htm");
}
else
{
reply.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "hero_notreceive.htm");
}
activeChar.sendPacket(reply);
break;
default:
_log.warning("Olympiad System: Couldnt send packet for request " + val);
break;
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return true;
}
@Override
public final String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,116 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.olympiad.Olympiad;
import com.l2jserver.gameserver.model.olympiad.OlympiadGameManager;
import com.l2jserver.gameserver.model.olympiad.OlympiadGameTask;
import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExOlympiadMatchList;
/**
* @author DS
*/
public class OlympiadObservation implements IBypassHandler
{
private static final String[] COMMANDS =
{
"watchmatch",
"arenachange"
};
@Override
public final boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
try
{
final L2Npc olymanager = activeChar.getLastFolkNPC();
if (command.startsWith(COMMANDS[0])) // list
{
if (!Olympiad.getInstance().inCompPeriod())
{
activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
return false;
}
activeChar.sendPacket(new ExOlympiadMatchList());
}
else
{
if ((olymanager == null) || !(olymanager instanceof L2OlympiadManagerInstance))
{
return false;
}
if (!activeChar.inObserverMode() && !activeChar.isInsideRadius(olymanager, 300, false, false))
{
return false;
}
if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
{
activeChar.sendPacket(SystemMessageId.YOU_MAY_NOT_OBSERVE_A_OLYMPIAD_GAMES_MATCH_WHILE_YOU_ARE_ON_THE_WAITING_LIST);
return false;
}
if (!Olympiad.getInstance().inCompPeriod())
{
activeChar.sendPacket(SystemMessageId.THE_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
return false;
}
if (activeChar.isOnEvent())
{
activeChar.sendMessage("You can not observe games while registered on an event");
return false;
}
final int arenaId = Integer.parseInt(command.substring(12).trim());
final OlympiadGameTask nextArena = OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
if (nextArena != null)
{
activeChar.enterOlympiadObserverMode(nextArena.getZone().getSpectatorSpawns().get(0), arenaId);
activeChar.setInstanceId(OlympiadGameManager.getInstance().getOlympiadTask(arenaId).getZone().getInstanceId());
}
}
return true;
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
@Override
public final String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.StringTokenizer;
import java.util.logging.Level;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class PlayerHelp implements IBypassHandler
{
private static final String[] COMMANDS =
{
"player_help"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
try
{
if (command.length() < 13)
{
return false;
}
final String path = command.substring(12);
if (path.indexOf("..") != -1)
{
return false;
}
final StringTokenizer st = new StringTokenizer(path);
final String[] cmd = st.nextToken().split("#");
final NpcHtmlMessage html;
if (cmd.length > 1)
{
final int itemId = Integer.parseInt(cmd[1]);
html = new NpcHtmlMessage(0, itemId);
}
else
{
html = new NpcHtmlMessage();
}
html.setFile(activeChar.getHtmlPrefix(), "data/html/help/" + cmd[0]);
activeChar.sendPacket(html);
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
import com.l2jserver.gameserver.network.serverpackets.WareHouseDepositList;
import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
public class PrivateWarehouse implements IBypassHandler
{
private static final String[] COMMANDS =
{
"withdrawp",
"withdrawsortedp",
"depositp"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
if (activeChar.isEnchanting())
{
return false;
}
try
{
if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawP
{
if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE)
{
final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
msg.setFile(activeChar.getHtmlPrefix(), "data/html/mods/WhSortedP.htm");
msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
activeChar.sendPacket(msg);
}
else
{
showWithdrawWindow(activeChar, null, (byte) 0);
}
return true;
}
else if (command.toLowerCase().startsWith(COMMANDS[1])) // WithdrawSortedP
{
final String param[] = command.split(" ");
if (param.length > 2)
{
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.getOrder(param[2]));
}
else if (param.length > 1)
{
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.A2Z);
}
else
{
showWithdrawWindow(activeChar, WarehouseListType.ALL, SortedWareHouseWithdrawalList.A2Z);
}
return true;
}
else if (command.toLowerCase().startsWith(COMMANDS[2])) // DepositP
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
activeChar.setActiveWarehouse(activeChar.getWarehouse());
activeChar.setInventoryBlockingStatus(true);
activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.PRIVATE));
return true;
}
return false;
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
private static final void showWithdrawWindow(L2PcInstance player, WarehouseListType itemtype, byte sortorder)
{
player.sendPacket(ActionFailed.STATIC_PACKET);
player.setActiveWarehouse(player.getWarehouse());
if (player.getActiveWarehouse().getSize() == 0)
{
player.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
return;
}
if (itemtype != null)
{
player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE, itemtype, sortorder));
}
else
{
player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.PRIVATE));
}
if (Config.DEBUG)
{
_log.fine("Source: L2WarehouseInstance.java; Player: " + player.getName() + "; Command: showRetrieveWindow; Message: Showing stored items.");
}
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,320 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import com.l2jserver.gameserver.datatables.NpcData;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jserver.gameserver.model.events.EventType;
import com.l2jserver.gameserver.model.events.listeners.AbstractEventListener;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.util.StringUtil;
public class QuestLink implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Quest"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
String quest = "";
try
{
quest = command.substring(5).trim();
}
catch (IndexOutOfBoundsException ioobe)
{
}
if (quest.length() == 0)
{
showQuestWindow(activeChar, (L2Npc) target);
}
else
{
int questNameEnd = quest.indexOf(" ");
if (questNameEnd == -1)
{
showQuestWindow(activeChar, (L2Npc) target, quest);
}
else
{
activeChar.processQuestEvent(quest.substring(0, questNameEnd), quest.substring(questNameEnd).trim());
}
}
return true;
}
/**
* Open a choose quest window on client with all quests available of the L2NpcInstance.<br>
* <b><u>Actions</u>:</b><br>
* <li>Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance</li>
* @param player The L2PcInstance that talk with the L2NpcInstance
* @param npc The table containing quests of the L2NpcInstance
* @param quests
*/
public static void showQuestChooseWindow(L2PcInstance player, L2Npc npc, Quest[] quests)
{
final StringBuilder sb = StringUtil.startAppend(150, "<html><body>");
String state = "";
String color = "";
int questId = -1;
for (Quest quest : quests)
{
if (quest == null)
{
continue;
}
final QuestState qs = player.getQuestState(quest.getScriptName());
if ((qs == null) || qs.isCreated())
{
state = quest.isCustomQuest() ? "" : "01";
if (quest.canStartQuest(player))
{
color = "bbaa88";
}
else
{
color = "a62f31";
}
}
else if (qs.isStarted())
{
state = quest.isCustomQuest() ? " (In Progress)" : "02";
color = "ffdd66";
}
else if (qs.isCompleted())
{
state = quest.isCustomQuest() ? " (Done)" : "03";
color = "787878";
}
StringUtil.append(sb, "<a action=\"bypass -h npc_", String.valueOf(npc.getObjectId()), "_Quest ", quest.getName(), "\">");
StringUtil.append(sb, "<font color=\"" + color + "\">[");
if (quest.isCustomQuest())
{
StringUtil.append(sb, quest.getDescr(), state);
}
else
{
questId = quest.getId();
if (quest.getId() > 10000)
{
questId -= 5000;
}
else if (questId == 146)
{
questId = 640;
}
StringUtil.append(sb, "<fstring>", String.valueOf(questId), state, "</fstring>");
}
sb.append("]</font></a><br>");
}
sb.append("</body></html>");
// Send a Server->Client packet NpcHtmlMessage to the L2PcInstance in order to display the message of the L2NpcInstance
npc.insertObjectIdAndShowChatWindow(player, sb.toString());
}
/**
* Open a quest window on client with the text of the L2NpcInstance.<br>
* <b><u>Actions</u>:</b><br>
* <ul>
* <li>Get the text of the quest state in the folder data/scripts/quests/questId/stateId.htm</li>
* <li>Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance</li>
* <li>Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet</li>
* </ul>
* @param player the L2PcInstance that talk with the {@code npc}
* @param npc the L2NpcInstance that chats with the {@code player}
* @param questId the Id of the quest to display the message
*/
public static void showQuestWindow(L2PcInstance player, L2Npc npc, String questId)
{
String content = null;
final Quest q = QuestManager.getInstance().getQuest(questId);
// Get the state of the selected quest
final QuestState qs = player.getQuestState(questId);
if (q != null)
{
if (((q.getId() >= 1) && (q.getId() < 20000)) && ((player.getWeightPenalty() >= 3) || !player.isInventoryUnder90(true)))
{
player.sendPacket(SystemMessageId.UNABLE_TO_PROCESS_THIS_REQUEST_UNTIL_YOUR_INVENTORY_S_WEIGHT_AND_SLOT_COUNT_ARE_LESS_THAN_80_PERCENT_OF_CAPACITY);
return;
}
if (qs == null)
{
if ((q.getId() >= 1) && (q.getId() < 20000))
{
// Too many ongoing quests.
if (player.getAllActiveQuests().length > 40)
{
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
html.setFile(player.getHtmlPrefix(), "data/html/fullquest.html");
player.sendPacket(html);
return;
}
}
}
q.notifyTalk(npc, player);
}
else
{
content = Quest.getNoQuestMsg(player); // no quests found
}
// Send a Server->Client packet NpcHtmlMessage to the L2PcInstance in order to display the message of the L2NpcInstance
if (content != null)
{
npc.insertObjectIdAndShowChatWindow(player, content);
}
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
player.sendPacket(ActionFailed.STATIC_PACKET);
}
/**
* @param player
* @param npcId The Identifier of the NPC
* @return a table containing all QuestState from the table _quests in which the L2PcInstance must talk to the NPC.
*/
private static List<QuestState> getQuestsForTalk(final L2PcInstance player, int npcId)
{
// Create a QuestState table that will contain all QuestState to modify
final List<QuestState> states = new ArrayList<>();
final L2NpcTemplate template = NpcData.getInstance().getTemplate(npcId);
if (template == null)
{
_log.log(Level.WARNING, QuestLink.class.getSimpleName() + ": " + player.getName() + " requested quests for talk on non existing npc " + npcId);
return states;
}
// Go through the QuestState of the L2PcInstance quests
for (AbstractEventListener listener : template.getListeners(EventType.ON_NPC_TALK))
{
if (listener.getOwner() instanceof Quest)
{
final Quest quest = (Quest) listener.getOwner();
// Copy the current L2PcInstance QuestState in the QuestState table
final QuestState st = player.getQuestState(quest.getName());
if (st != null)
{
states.add(st);
}
}
}
// Return a table containing all QuestState to modify
return states;
}
/**
* Collect awaiting quests/start points and display a QuestChooseWindow (if several available) or QuestWindow.
* @param player the L2PcInstance that talk with the {@code npc}.
* @param npc the L2NpcInstance that chats with the {@code player}.
*/
public static void showQuestWindow(L2PcInstance player, L2Npc npc)
{
boolean conditionMeet = false;
// collect awaiting quests and start points
final Set<Quest> options = new HashSet<>();
// Quests are limited between 1 and 999 because those are the quests that are supported by the client.
// By limiting them there, we are allowed to create custom quests at higher IDs without interfering
for (QuestState state : getQuestsForTalk(player, npc.getId()))
{
final Quest quest = state.getQuest();
if (quest == null)
{
_log.log(Level.WARNING, player + " Requested incorrect quest state for non existing quest: " + state.getQuestName());
continue;
}
if ((quest.getId() > 0) && (quest.getId() < 20000))
{
options.add(quest);
if (quest.canStartQuest(player))
{
conditionMeet = true;
}
}
}
for (AbstractEventListener listener : npc.getListeners(EventType.ON_NPC_QUEST_START))
{
if (listener.getOwner() instanceof Quest)
{
final Quest quest = (Quest) listener.getOwner();
if ((quest.getId() > 0) && (quest.getId() < 20000))
{
options.add(quest);
if (quest.canStartQuest(player))
{
conditionMeet = true;
}
}
}
}
if (!conditionMeet)
{
showQuestWindow(player, npc, "");
}
else if (options.size() > 1)
{
showQuestChooseWindow(player, npc, options.toArray(new Quest[options.size()]));
}
else if (options.size() == 1)
{
showQuestWindow(player, npc, options.stream().findFirst().get().getName());
}
else
{
showQuestWindow(player, npc, "");
}
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2AdventurerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExShowQuestInfo;
public class QuestList implements IBypassHandler
{
private static final String[] COMMANDS =
{
"questlist"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2AdventurerInstance))
{
return false;
}
activeChar.sendPacket(ExShowQuestInfo.STATIC_PACKET);
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExGetPremiumItemList;
public class ReceivePremium implements IBypassHandler
{
private static final String[] COMMANDS =
{
"ReceivePremium"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
if (activeChar.getPremiumItemList().isEmpty())
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_MORE_DIMENSIONAL_ITEMS_TO_BE_FOUND);
return false;
}
activeChar.sendPacket(new ExGetPremiumItemList(activeChar));
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExShowBaseAttributeCancelWindow;
public class ReleaseAttribute implements IBypassHandler
{
private static final String[] COMMANDS =
{
"ReleaseAttribute"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
activeChar.sendPacket(new ExShowBaseAttributeCancelWindow(activeChar));
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,146 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.StringTokenizer;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SetupGauge;
public class RentPet implements IBypassHandler
{
private static final String[] COMMANDS =
{
"RentPet"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2MerchantInstance))
{
return false;
}
if (!Config.ALLOW_RENTPET)
{
return false;
}
if (!Config.LIST_PET_RENT_NPC.contains(target.getId()))
{
return false;
}
try
{
StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
if (st.countTokens() < 1)
{
final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
msg.setHtml("<html><body>Pet Manager:<br>" + "You can rent a wyvern or strider for adena.<br>My prices:<br1>" + "<table border=0><tr><td>Ride</td></tr>" + "<tr><td>Wyvern</td><td>Strider</td></tr>" + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 1\">30 sec/1800 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 11\">30 sec/900 adena</a></td></tr>" + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 2\">1 min/7200 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 12\">1 min/3600 adena</a></td></tr>" + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 3\">10 min/720000 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 13\">10 min/360000 adena</a></td></tr>" + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 4\">30 min/6480000 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 14\">30 min/3240000 adena</a></td></tr>" + "</table>" + "</body></html>");
msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
activeChar.sendPacket(msg);
}
else
{
tryRentPet(activeChar, Integer.parseInt(st.nextToken()));
}
return true;
}
catch (Exception e)
{
_log.info("Exception in " + getClass().getSimpleName());
}
return false;
}
public static final void tryRentPet(L2PcInstance player, int val)
{
if ((player == null) || player.hasSummon() || player.isMounted() || player.isRentedPet() || player.isTransformed() || player.isCursedWeaponEquipped())
{
return;
}
if (!player.disarmWeapons())
{
return;
}
int petId;
double price = 1;
int cost[] =
{
1800,
7200,
720000,
6480000
};
int ridetime[] =
{
30,
60,
600,
1800
};
if (val > 10)
{
petId = 12526;
val -= 10;
price /= 2;
}
else
{
petId = 12621;
}
if ((val < 1) || (val > 4))
{
return;
}
price *= cost[val - 1];
int time = ridetime[val - 1];
if (!player.reduceAdena("Rent", (long) price, player.getLastFolkNPC(), true))
{
return;
}
player.mount(petId, 0, false);
SetupGauge sg = new SetupGauge(3, time * 1000);
player.sendPacket(sg);
player.startRentPet(time);
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,139 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.List;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillTreesData;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class SkillList implements IBypassHandler
{
private static final String[] COMMANDS =
{
"SkillList"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2NpcInstance))
{
return false;
}
if (Config.ALT_GAME_SKILL_LEARN)
{
try
{
String id = command.substring(9).trim();
if (id.length() != 0)
{
L2NpcInstance.showSkillList(activeChar, (L2Npc) target, ClassId.getClassId(Integer.parseInt(id)));
}
else
{
boolean own_class = false;
final List<ClassId> classesToTeach = ((L2NpcInstance) target).getClassesToTeach();
for (ClassId cid : classesToTeach)
{
if (cid.equalsOrChildOf(activeChar.getClassId()))
{
own_class = true;
break;
}
}
String text = "<html><body><center>Skill learning:</center><br>";
if (!own_class)
{
String charType = activeChar.getClassId().isMage() ? "fighter" : "mage";
text += "Skills of your class are the easiest to learn.<br>" + "Skills of another class of your race are a little harder.<br>" + "Skills for classes of another race are extremely difficult.<br>" + "But the hardest of all to learn are the " + charType + "skills!<br>";
}
// make a list of classes
if (!classesToTeach.isEmpty())
{
int count = 0;
ClassId classCheck = activeChar.getClassId();
while ((count == 0) && (classCheck != null))
{
for (ClassId cid : classesToTeach)
{
if (cid.level() > classCheck.level())
{
continue;
}
if (SkillTreesData.getInstance().getAvailableSkills(activeChar, cid, false, false).isEmpty())
{
continue;
}
text += "<a action=\"bypass -h npc_%objectId%_SkillList " + cid.getId() + "\">Learn " + cid + "'s class Skills</a><br>\n";
count++;
}
classCheck = classCheck.getParent();
}
classCheck = null;
}
else
{
text += "No Skills.<br>";
}
text += "</body></html>";
final NpcHtmlMessage html = new NpcHtmlMessage(((L2Npc) target).getObjectId());
html.setHtml(text);
html.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
activeChar.sendPacket(html);
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
}
else
{
L2NpcInstance.showSkillList(activeChar, (L2Npc) target, activeChar.getClassId());
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.CommonSkill;
public class SupportBlessing implements IBypassHandler
{
private static final String[] COMMANDS =
{
"GiveBlessing"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
final L2Npc npc = (L2Npc) target;
// If the player is too high level, display a message and return
if ((activeChar.getLevel() > 39) || (activeChar.getClassId().level() >= 2))
{
npc.showChatWindow(activeChar, "data/html/default/SupportBlessingHighLevel.htm");
return true;
}
npc.setTarget(activeChar);
npc.doCast(CommonSkill.BLESSING_OF_PROTECTION.getSkill());
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,179 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.enums.CategoryType;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
public class SupportMagic implements IBypassHandler
{
private static final String[] COMMANDS =
{
"supportmagicservitor",
"supportmagic"
};
// Buffs
private static final SkillHolder HASTE_1 = new SkillHolder(4327, 1);
private static final SkillHolder HASTE_2 = new SkillHolder(5632, 1);
private static final SkillHolder CUBIC = new SkillHolder(4338, 1);
private static final SkillHolder[] FIGHTER_BUFFS =
{
new SkillHolder(4322, 1), // Wind Walk
new SkillHolder(4323, 1), // Shield
new SkillHolder(5637, 1), // Magic Barrier
new SkillHolder(4324, 1), // Bless the Body
new SkillHolder(4325, 1), // Vampiric Rage
new SkillHolder(4326, 1), // Regeneration
};
private static final SkillHolder[] MAGE_BUFFS =
{
new SkillHolder(4322, 1), // Wind Walk
new SkillHolder(4323, 1), // Shield
new SkillHolder(5637, 1), // Magic Barrier
new SkillHolder(4328, 1), // Bless the Soul
new SkillHolder(4329, 1), // Acumen
new SkillHolder(4330, 1), // Concentration
new SkillHolder(4331, 1), // Empower
};
private static final SkillHolder[] SUMMON_BUFFS =
{
new SkillHolder(4322, 1), // Wind Walk
new SkillHolder(4323, 1), // Shield
new SkillHolder(5637, 1), // Magic Barrier
new SkillHolder(4324, 1), // Bless the Body
new SkillHolder(4325, 1), // Vampiric Rage
new SkillHolder(4326, 1), // Regeneration
new SkillHolder(4328, 1), // Bless the Soul
new SkillHolder(4329, 1), // Acumen
new SkillHolder(4330, 1), // Concentration
new SkillHolder(4331, 1), // Empower
};
// Levels
private static final int LOWEST_LEVEL = 6;
private static final int HIGHEST_LEVEL = 75;
private static final int CUBIC_LOWEST = 16;
private static final int CUBIC_HIGHEST = 34;
private static final int HASTE_LEVEL_2 = 40;
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc() || activeChar.isCursedWeaponEquipped())
{
return false;
}
if (command.equalsIgnoreCase(COMMANDS[0]))
{
makeSupportMagic(activeChar, (L2Npc) target, true);
}
else if (command.equalsIgnoreCase(COMMANDS[1]))
{
makeSupportMagic(activeChar, (L2Npc) target, false);
}
return true;
}
private static void makeSupportMagic(L2PcInstance player, L2Npc npc, boolean isSummon)
{
final int level = player.getLevel();
if (isSummon && !player.hasServitor())
{
npc.showChatWindow(player, "data/html/default/SupportMagicNoSummon.htm");
return;
}
else if (level > HIGHEST_LEVEL)
{
npc.showChatWindow(player, "data/html/default/SupportMagicHighLevel.htm");
return;
}
else if (level < LOWEST_LEVEL)
{
npc.showChatWindow(player, "data/html/default/SupportMagicLowLevel.htm");
return;
}
else if (player.getClassId().level() == 3)
{
player.sendMessage("Only adventurers who have not completed their 3rd class transfer may receive these buffs."); // Custom message
return;
}
if (isSummon)
{
npc.setTarget(player.getSummon());
for (SkillHolder skill : SUMMON_BUFFS)
{
npc.doCast(skill.getSkill());
}
if (level >= HASTE_LEVEL_2)
{
npc.doCast(HASTE_2.getSkill());
}
else
{
npc.doCast(HASTE_1.getSkill());
}
}
else
{
npc.setTarget(player);
if (player.isInCategory(CategoryType.BEGINNER_MAGE))
{
for (SkillHolder skill : MAGE_BUFFS)
{
npc.doCast(skill.getSkill());
}
}
else
{
for (SkillHolder skill : FIGHTER_BUFFS)
{
npc.doCast(skill.getSkill());
}
if (level >= HASTE_LEVEL_2)
{
npc.doCast(HASTE_2.getSkill());
}
else
{
npc.doCast(HASTE_1.getSkill());
}
}
if ((level >= CUBIC_LOWEST) && (level <= CUBIC_HIGHEST))
{
player.doSimultaneousCast(CUBIC.getSkill());
}
}
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class TerritoryStatus implements IBypassHandler
{
private static final String[] COMMANDS =
{
"TerritoryStatus"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
final L2Npc npc = (L2Npc) target;
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
{
if (npc.getCastle().getOwnerId() > 0)
{
html.setFile(activeChar.getHtmlPrefix(), "data/html/territorystatus.htm");
L2Clan clan = ClanTable.getInstance().getClan(npc.getCastle().getOwnerId());
html.replace("%clanname%", clan.getName());
html.replace("%clanleadername%", clan.getLeaderName());
}
else
{
html.setFile(activeChar.getHtmlPrefix(), "data/html/territorynoclan.htm");
}
}
html.replace("%castlename%", npc.getCastle().getName());
html.replace("%taxpercent%", "" + npc.getCastle().getTaxPercent());
html.replace("%objectId%", String.valueOf(npc.getObjectId()));
{
if (npc.getCastle().getResidenceId() > 6)
{
html.replace("%territory%", "The Kingdom of Elmore");
}
else
{
html.replace("%territory%", "The Kingdom of Aden");
}
}
activeChar.sendPacket(html);
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.TutorialCloseHtml;
/**
* @author UnAfraid
*/
public class TutorialClose implements IBypassHandler
{
private static final String[] COMMANDS =
{
"tutorial_close",
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
activeChar.sendPacket(TutorialCloseHtml.STATIC_PACKET);
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author DS
*/
public class VoiceCommand implements IBypassHandler
{
private static final String[] COMMANDS =
{
"voice"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
// only voice commands allowed
if ((command.length() > 7) && (command.charAt(6) == '.'))
{
final String vc, vparams;
int endOfCommand = command.indexOf(" ", 7);
if (endOfCommand > 0)
{
vc = command.substring(7, endOfCommand).trim();
vparams = command.substring(endOfCommand).trim();
}
else
{
vc = command.substring(7).trim();
vparams = null;
}
if (vc.length() > 0)
{
IVoicedCommandHandler vch = VoicedCommandHandler.getInstance().getHandler(vc);
if (vch != null)
{
return vch.useVoicedCommand(vc, activeChar, vparams);
}
}
}
return false;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.bypasshandlers;
import java.util.StringTokenizer;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.BuyListData;
import com.l2jserver.gameserver.handler.IBypassHandler;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.buylist.L2BuyList;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ShopPreviewList;
public class Wear implements IBypassHandler
{
private static final String[] COMMANDS =
{
"Wear"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!target.isNpc())
{
return false;
}
if (!Config.ALLOW_WEAR)
{
return false;
}
try
{
StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
if (st.countTokens() < 1)
{
return false;
}
showWearWindow(activeChar, Integer.parseInt(st.nextToken()));
return true;
}
catch (Exception e)
{
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
}
return false;
}
private static final void showWearWindow(L2PcInstance player, int val)
{
final L2BuyList buyList = BuyListData.getInstance().getBuyList(val);
if (buyList == null)
{
_log.warning("BuyList not found! BuyListId:" + val);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
player.setInventoryBlockingStatus(true);
player.sendPacket(new ShopPreviewList(buyList, player.getAdena(), player.getExpertiseLevel()));
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}