Chronicle 4 branch.

This commit is contained in:
MobiusDev
2017-07-19 21:24:06 +00:00
parent 9a69bec286
commit 3a0bf3539a
13496 changed files with 641683 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import javolution.util.FastMap;
/**
* This class ...
* @version $Revision: 1.1.4.5 $ $Date: 2005/03/27 15:30:09 $
*/
public class AdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminCommandHandler.class.getName());
private static AdminCommandHandler _instance;
private final Map<String, IAdminCommandHandler> _datatable;
// Alt privileges setting
private static Logger _priviLog = Logger.getLogger("AltPrivilegesAdmin");
private static FastMap<String, Integer> _privileges;
public static AdminCommandHandler getInstance()
{
if (_instance == null)
{
_instance = new AdminCommandHandler();
}
return _instance;
}
private AdminCommandHandler()
{
_datatable = new FastMap<>();
}
public void registerAdminCommandHandler(IAdminCommandHandler handler)
{
final String[] ids = handler.getAdminCommandList();
for (final String id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for command " + id);
}
_datatable.put(new String(id), handler);
}
}
public IAdminCommandHandler getAdminCommandHandler(String adminCommand)
{
String command = adminCommand;
if (adminCommand.indexOf(" ") != -1)
{
command = adminCommand.substring(0, adminCommand.indexOf(" "));
}
if (Config.DEBUG)
{
_log.fine("getting handler for command: " + command + " -> " + (_datatable.get(new String(command)) != null));
}
return _datatable.get(command);
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
public final boolean checkPrivileges(L2PcInstance player, String adminCommand)
{
// Only a GM can execute a admin command
if (!player.isGM())
{
return false;
}
// Skip special privileges handler?
if (!Config.ALT_PRIVILEGES_ADMIN || Config.EVERYBODY_HAS_ADMIN_RIGHTS)
{
return true;
}
if (_privileges == null)
{
_privileges = new FastMap<>();
}
String command = adminCommand;
if (adminCommand.indexOf(" ") != -1)
{
command = adminCommand.substring(0, adminCommand.indexOf(" "));
}
// The command not exists
if (!_datatable.containsKey(command))
{
return false;
}
int requireLevel = 0;
if (!_privileges.containsKey(command))
{
// Try to loaded the command config
boolean isLoaded = false;
final Properties Settings = new Properties();
try (InputStream is = new FileInputStream(Config.COMMAND_PRIVILEGES_FILE))
{
Settings.load(is);
}
catch (final Exception e)
{
}
final String stringLevel = Settings.getProperty(command);
if (stringLevel != null)
{
isLoaded = true;
requireLevel = Integer.parseInt(stringLevel);
}
// Secure level?
if (!isLoaded)
{
if (Config.ALT_PRIVILEGES_SECURE_CHECK)
{
_priviLog.info("The command '" + command + "' haven't got a entry in the configuration file. The command cannot be executed!!");
return false;
}
requireLevel = Config.ALT_PRIVILEGES_DEFAULT_LEVEL;
}
_privileges.put(command, requireLevel);
}
else
{
requireLevel = _privileges.get(command);
}
if (player.getAccessLevel() < requireLevel)
{
_priviLog.warning("<GM>" + player.getName() + ": have not access level to execute the command '" + command + "'");
return false;
}
return true;
}
}

View File

@@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
*/
public interface IAdminCommandHandler
{
/**
* this is the worker method that is called when someone uses an admin command.
* @param activeChar
* @param command
* @return command success
*/
public boolean useAdminCommand(String command, L2PcInstance activeChar);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public String[] getAdminCommandList();
}

View File

@@ -0,0 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
/**
* Mother class of all itemHandlers.<BR>
* <BR>
* an IItemHandler implementation has to be stateless
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:09 $
*/
public interface IItemHandler
{
/**
* Launch task associated to the item.
* @param playable : L2PlayableInstance designating the player
* @param item : L2ItemInstance designating the item to use
*/
public void useItem(L2PlayableInstance playable, L2ItemInstance item);
/**
* Returns the list of item IDs corresponding to the type of item.<BR>
* <BR>
* <B><I>Use :</I></U><BR>
* This method is called at initialization to register all the item IDs automatically
* @return int[] designating all itemIds for a type of item.
*/
public int[] getItemIds();
}

View File

@@ -0,0 +1,47 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import java.io.IOException;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
/**
* an IItemHandler implementation has to be stateless
* @version $Revision: 1.2.2.2.2.3 $ $Date: 2005/04/03 15:55:06 $
*/
public interface ISkillHandler
{
/**
* this is the working method that is called when using a skill.
* @param activeChar
* @param skill
* @param targets
* @param crit
* @throws IOException
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets, boolean crit) throws IOException;
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public SkillType[] getSkillIds();
}

View File

@@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.2 $ $Date: 2005/03/27 15:30:10 $
*/
public interface IUserCommandHandler
{
/**
* this is the worker method that is called when someone uses an admin command.
* @param id
* @param activeChar
* @return command success
*/
public boolean useUserCommand(int id, L2PcInstance activeChar);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public int[] getUserCommandList();
}

View File

@@ -0,0 +1,41 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
*/
public interface IVoicedCommandHandler
{
/**
* this is the worker method that is called when someone uses an admin command.
* @param activeChar
* @param command
* @param target
* @return command success
*/
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public String[] getVoicedCommandList();
}

View File

@@ -0,0 +1,91 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import java.util.Map;
import java.util.TreeMap;
/**
* This class manages handlers of items
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:09 $
*/
public class ItemHandler
{
// private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
private static ItemHandler _instance;
private final Map<Integer, IItemHandler> _datatable;
/**
* Create ItemHandler if doesn't exist and returns ItemHandler
* @return ItemHandler
*/
public static ItemHandler getInstance()
{
if (_instance == null)
{
_instance = new ItemHandler();
}
return _instance;
}
/**
* Returns the number of elements contained in datatable
* @return int : Size of the datatable
*/
public int size()
{
return _datatable.size();
}
/**
* Constructor of ItemHandler
*/
private ItemHandler()
{
_datatable = new TreeMap<>();
}
/**
* Adds handler of item type in <I>datatable</I>.<BR>
* <BR>
* <B><I>Concept :</I></U><BR>
* This handler is put in <I>datatable</I> Map &lt;Integer ; IItemHandler &gt; for each ID corresponding to an item type (existing in classes of package itemhandlers) sets as key of the Map.
* @param handler (IItemHandler)
*/
public void registerItemHandler(IItemHandler handler)
{
// Get all ID corresponding to the item type of the handler
final int[] ids = handler.getItemIds();
// Add handler for each ID found
for (final int id : ids)
{
_datatable.put(new Integer(id), handler);
}
}
/**
* Returns the handler of the item
* @param itemId : int designating the itemID
* @return IItemHandler
*/
public IItemHandler getItemHandler(int itemId)
{
return _datatable.get(new Integer(itemId));
}
}

View File

@@ -0,0 +1,72 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import java.util.Map;
import java.util.TreeMap;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
/**
* This class ...
* @version $Revision: 1.1.4.4 $ $Date: 2005/04/03 15:55:06 $
*/
public class SkillHandler
{
// private static Logger _log = Logger.getLogger(SkillHandler.class.getName());
private static SkillHandler _instance;
private final Map<L2Skill.SkillType, ISkillHandler> _datatable;
public static SkillHandler getInstance()
{
if (_instance == null)
{
_instance = new SkillHandler();
}
return _instance;
}
private SkillHandler()
{
_datatable = new TreeMap<>();
}
public void registerSkillHandler(ISkillHandler handler)
{
final SkillType[] types = handler.getSkillIds();
for (final SkillType t : types)
{
_datatable.put(t, handler);
}
}
public ISkillHandler getSkillHandler(SkillType skillType)
{
return _datatable.get(skillType);
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
}

View File

@@ -0,0 +1,81 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import javolution.util.FastMap;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.5 $ $Date: 2005/03/27 15:30:09 $
*/
public class UserCommandHandler
{
private static Logger _log = Logger.getLogger(UserCommandHandler.class.getName());
private static UserCommandHandler _instance;
private final Map<Integer, IUserCommandHandler> _datatable;
public static UserCommandHandler getInstance()
{
if (_instance == null)
{
_instance = new UserCommandHandler();
}
return _instance;
}
private UserCommandHandler()
{
_datatable = new FastMap<>();
}
public void registerUserCommandHandler(IUserCommandHandler handler)
{
final int[] ids = handler.getUserCommandList();
for (final int id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for user command " + id);
}
_datatable.put(new Integer(id), handler);
}
}
public IUserCommandHandler getUserCommandHandler(int userCommand)
{
if (Config.DEBUG)
{
_log.fine("getting handler for user command: " + userCommand);
}
return _datatable.get(new Integer(userCommand));
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
}

View File

@@ -0,0 +1,86 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import javolution.util.FastMap;
/**
* This class ...
* @version $Revision: 1.1.4.5 $ $Date: 2005/03/27 15:30:09 $
*/
public class VoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
private static VoicedCommandHandler _instance;
private final Map<String, IVoicedCommandHandler> _datatable;
public static VoicedCommandHandler getInstance()
{
if (_instance == null)
{
_instance = new VoicedCommandHandler();
}
return _instance;
}
private VoicedCommandHandler()
{
_datatable = new FastMap<>();
}
public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
{
final String[] ids = handler.getVoicedCommandList();
for (final String id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for command " + id);
}
_datatable.put(new String(id), handler);
}
}
public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
{
String command = voicedCommand;
if (voicedCommand.indexOf(" ") != -1)
{
command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
}
if (Config.DEBUG)
{
_log.fine("getting handler for command: " + command + " -> " + (_datatable.get(new String(command)) != null));
}
return _datatable.get(command);
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
}

View File

@@ -0,0 +1,437 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.Olympiad;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.datatables.GmListTable;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.datatables.NpcTable;
import com.l2jmobius.gameserver.datatables.NpcWalkerRoutesTable;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.datatables.TeleportLocationTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.Manager;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.model.EventEngine;
import com.l2jmobius.gameserver.model.L2Multisell;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.SignsSky;
import com.l2jmobius.gameserver.network.serverpackets.SunRise;
import com.l2jmobius.gameserver.network.serverpackets.SunSet;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - admin = shows menu
* @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminAdmin implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_admin",
"admin_play_sounds",
"admin_play_sound",
"admin_gmliston",
"admin_gmlistoff",
"admin_silence",
"admin_atmosphere",
"admin_diet",
"admin_tradeoff",
"admin_reload",
"admin_set",
"admin_saveolymp",
"admin_endolympiad",
"admin_sethero",
"admin_setnoble"
};
private static final int REQUIRED_LEVEL = Config.GM_MENU;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_admin"))
{
showMainPage(activeChar);
}
else if (command.equals("admin_play_sounds"))
{
AdminHelpPage.showHelpPage(activeChar, "songs/songs.htm");
}
else if (command.startsWith("admin_play_sounds"))
{
try
{
AdminHelpPage.showHelpPage(activeChar, "songs/songs" + command.substring(17) + ".htm");
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_play_sound"))
{
try
{
playAdminSound(activeChar, command.substring(17));
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_gmliston"))
{
GmListTable.getInstance().showGm(activeChar);
activeChar.sendMessage("Registered into gm list.");
}
else if (command.startsWith("admin_gmlistoff"))
{
GmListTable.getInstance().hideGm(activeChar);
activeChar.sendMessage("Removed from gm list.");
}
else if (command.startsWith("admin_silence"))
{
if (activeChar.getMessageRefusal()) // already in message refusal mode
{
activeChar.setMessageRefusal(false);
activeChar.sendPacket(new SystemMessage(SystemMessage.MESSAGE_ACCEPTANCE_MODE));
}
else
{
activeChar.setMessageRefusal(true);
activeChar.sendPacket(new SystemMessage(SystemMessage.MESSAGE_REFUSAL_MODE));
}
}
else if (command.startsWith("admin_saveolymp"))
{
try
{
Olympiad.getInstance().save();
activeChar.sendMessage("Olympiad data saved!!");
}
catch (final Exception e)
{
e.printStackTrace();
}
}
else if (command.startsWith("admin_endolympiad"))
{
try
{
Olympiad.getInstance().manualSelectHeroes();
activeChar.sendMessage("Heroes were formed.");
}
catch (final Exception e)
{
e.printStackTrace();
}
}
else if (command.startsWith("admin_sethero"))
{
L2PcInstance target = activeChar;
if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
{
target = (L2PcInstance) activeChar.getTarget();
}
target.setHero(target.isHero() ? false : true);
target.broadcastUserInfo();
}
else if (command.startsWith("admin_setnoble"))
{
L2PcInstance target = activeChar;
if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
{
target = (L2PcInstance) activeChar.getTarget();
}
target.setNoble(target.isNoble() ? false : true);
if (target.isNoble())
{
activeChar.sendMessage(target.getName() + " has gained Noblesse status.");
}
else
{
activeChar.sendMessage(target.getName() + " has lost Noblesse status.");
}
}
else if (command.startsWith("admin_atmosphere"))
{
try
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
final String type = st.nextToken();
final String state = st.nextToken();
adminAtmosphere(type, state, activeChar);
}
catch (final Exception ex)
{
}
}
else if (command.startsWith("admin_diet"))
{
try
{
if (!activeChar.getDietMode())
{
activeChar.setDietMode(true);
activeChar.sendMessage("Diet mode on.");
}
else
{
activeChar.setDietMode(false);
activeChar.sendMessage("Diet mode off.");
}
activeChar.refreshOverloaded();
}
catch (final Exception ex)
{
}
}
else if (command.startsWith("admin_tradeoff"))
{
try
{
final String mode = command.substring(15);
if (mode.equalsIgnoreCase("on"))
{
activeChar.setTradeRefusal(true);
activeChar.sendMessage("Tradeoff enabled.");
}
else if (mode.equalsIgnoreCase("off"))
{
activeChar.setTradeRefusal(false);
activeChar.sendMessage("Tradeoff disabled.");
}
}
catch (final Exception ex)
{
if (activeChar.getTradeRefusal())
{
activeChar.sendMessage("Tradeoff currently enabled.");
}
else
{
activeChar.sendMessage("Tradeoff currently disabled.");
}
}
}
else if (command.startsWith("admin_reload"))
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
try
{
final String type = st.nextToken();
if (type.startsWith("multisell"))
{
L2Multisell.getInstance().reload();
activeChar.sendMessage("All Multisells have been reloaded.");
}
else if (type.startsWith("teleport"))
{
TeleportLocationTable.getInstance().reloadAll();
activeChar.sendMessage("Teleport location table has been reloaded.");
}
else if (type.startsWith("skill"))
{
SkillTable.getInstance().reload();
activeChar.sendMessage("All Skills have been reloaded.");
}
else if (type.startsWith("npc"))
{
NpcTable.getInstance().reloadAllNpc();
activeChar.sendMessage("All NPCs have been reloaded.");
}
else if (type.startsWith("htm"))
{
HtmCache.getInstance().reload();
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded.");
}
else if (type.startsWith("item"))
{
ItemTable.getInstance().reload();
activeChar.sendMessage("All Item templates have been reloaded.");
}
else if (type.startsWith("config"))
{
Config.load();
activeChar.sendMessage("All config settings have been reload");
}
else if (type.startsWith("instancemanager"))
{
Manager.reloadAll();
activeChar.sendMessage("All instance managers have been reloaded.");
}
else if (type.startsWith("npcwalker"))
{
NpcWalkerRoutesTable.getInstance().load();
activeChar.sendMessage("All NPC walker routes have been reloaded.");
}
else if (type.startsWith("quest"))
{
QuestManager.getInstance().reloadAllQuests();
activeChar.sendMessage("All Quests have been reloaded.");
}
else if (type.startsWith("event"))
{
EventEngine.load();
activeChar.sendMessage("All Events have been reloaded.");
}
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //reload <multisell|skill|npc|htm|item|instancemanager>");
}
}
else if (command.startsWith("admin_set"))
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
try
{
final String[] parameter = st.nextToken().split("=");
final String pName = parameter[0].trim();
final String pValue = parameter[1].trim();
if (Config.setParameterValue(pName, pValue))
{
activeChar.sendMessage("Parameter set succesfully.");
}
else
{
activeChar.sendMessage("Invalid parameter!");
}
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //set parameter=value");
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
/**
* @param type - atmosphere type (signssky,sky)
* @param state - atmosphere state(night,day)
* @param activeChar
*/
public void adminAtmosphere(String type, String state, L2PcInstance activeChar)
{
L2GameServerPacket packet = null;
if (type.equals("signsky"))
{
if (state.equals("dawn"))
{
packet = new SignsSky(2);
}
else if (state.equals("dusk"))
{
packet = new SignsSky(1);
}
}
else if (type.equals("sky"))
{
if (state.equals("night"))
{
packet = new SunSet();
}
else if (state.equals("day"))
{
packet = new SunRise();
}
}
else
{
activeChar.sendMessage("Only sky and signsky atmosphere type allowed, damn u!");
}
if (packet != null)
{
for (final L2PcInstance player : L2World.getInstance().getAllPlayers())
{
player.sendPacket(packet);
}
}
}
public void playAdminSound(L2PcInstance activeChar, String sound)
{
final PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
activeChar.sendPacket(_snd);
activeChar.broadcastPacket(_snd);
showMainPage(activeChar);
activeChar.sendMessage("Playing " + sound + ".");
}
public void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage(5);
html.setFile("data/html/admin/adminpanel.htm");
activeChar.sendPacket(html);
}
}

View File

@@ -0,0 +1,136 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.Announcements;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.taskmanager.AutoAnnounceTaskManager;
/**
* This class handles following admin commands: - announce text = announces text to all players - list_announcements = show menu - reload_announcements = reloads announcements from txt file - announce_announcements = announce all stored announcements to all players - add_announcement text = adds
* text to startup announcements - del_announcement id = deletes announcement with respective id
* @version $Revision: 1.4.4.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminAnnouncements implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_list_announcements",
"admin_reload_announcements",
"admin_announce_announcements",
"admin_add_announcement",
"admin_del_announcement",
"admin_announce",
"admin_announce_menu",
"admin_reload_autoannounce"
};
private static final int REQUIRED_LEVEL = Config.GM_ANNOUNCE;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_list_announcements"))
{
Announcements.getInstance().listAnnouncements(activeChar);
}
else if (command.equals("admin_reload_announcements"))
{
Announcements.getInstance().loadAnnouncements();
Announcements.getInstance().listAnnouncements(activeChar);
}
else if (command.startsWith("admin_announce_menu"))
{
final Announcements sys = new Announcements();
sys.handleAnnounce(command, 20);
Announcements.getInstance().listAnnouncements(activeChar);
}
else if (command.equals("admin_announce_announcements"))
{
for (final L2PcInstance player : L2World.getInstance().getAllPlayers())
{
Announcements.getInstance().showAnnouncements(player);
}
Announcements.getInstance().listAnnouncements(activeChar);
}
else if (command.startsWith("admin_add_announcement"))
{
// FIXME the player can send only 16 chars (if you try to send more it sends null), remove this function or not?
if (!command.equals("admin_add_announcement"))
{
try
{
final String val = command.substring(23);
Announcements.getInstance().addAnnouncement(val);
Announcements.getInstance().listAnnouncements(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
// ignore errors
}
}
}
else if (command.startsWith("admin_del_announcement"))
{
try
{
final int val = new Integer(command.substring(23)).intValue();
Announcements.getInstance().delAnnouncement(val);
Announcements.getInstance().listAnnouncements(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_announce")) // Command is admin announce
{
// Call method from another class
final Announcements sys = new Announcements();
sys.handleAnnounce(command, 15);
}
else if (command.startsWith("admin_reload_autoannounce"))
{
AutoAnnounceTaskManager.getInstance().restore();
activeChar.sendMessage("AutoAnnouncement(s) Reloaded.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.communitybbs.Manager.AdminBBSManager;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class AdminBBS implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_bbs"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
AdminBBSManager.getInstance().parsecmd(command, activeChar);
return true;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
*/
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,266 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - kill = kills target L2Character
* @version $Revision: 1.1.6.3 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminBan implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminBan.class.getName());
private static String[] _adminCommands =
{
"admin_ban",
"admin_unban",
"admin_jail",
"admin_unjail"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (activeChar.getAccessLevel() < Config.GM_BAN)
{
return false;
}
}
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
String player = "";
L2PcInstance plyr = null;
if (command.startsWith("admin_ban"))
{
try
{
player = st.nextToken();
plyr = L2World.getInstance().getPlayer(player);
}
catch (final Exception e)
{
final L2Object target = activeChar.getTarget();
if ((target != null) && (target instanceof L2PcInstance))
{
plyr = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("Wrong parameter or target.");
}
}
if ((plyr != null) && (plyr == activeChar))
{
activeChar.sendMessage("You cannot use it on yourself.");
}
else if (plyr == null)
{
LoginServerThread.getInstance().sendAccessLevel(player, -100);
activeChar.sendMessage("This player is not ingame, so an account ban request was sent for " + player + " in case this name belongs to an account.");
}
else
{
plyr.setAccountAccesslevel(-100);
activeChar.sendMessage("Account of " + plyr.getName() + " was banned.");
plyr.logout();
}
}
else if (command.startsWith("admin_unban"))
{
try
{
player = st.nextToken();
LoginServerThread.getInstance().sendAccessLevel(player, 0);
activeChar.sendMessage("Unban request was sent for account " + player + ".");
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //unban <account_name>");
if (Config.DEBUG)
{
e.printStackTrace();
}
}
}
else if (command.startsWith("admin_jail"))
{
try
{
player = st.nextToken();
int delay = 0;
try
{
delay = Integer.parseInt(st.nextToken());
}
catch (final NumberFormatException nfe)
{
activeChar.sendMessage("Usage: //jail <charname> [penalty_minutes]");
}
catch (final NoSuchElementException nsee)
{
}
final L2PcInstance playerObj = L2World.getInstance().getPlayer(player);
if (playerObj != null)
{
playerObj.setInJail(true, delay);
activeChar.sendMessage("Character " + player + " has been jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
}
else
{
jailOfflinePlayer(activeChar, player, delay);
}
}
catch (final NoSuchElementException nsee)
{
activeChar.sendMessage("Usage: //jail <charname> [penalty_minutes]");
}
catch (final Exception e)
{
if (Config.DEBUG)
{
e.printStackTrace();
}
}
}
else if (command.startsWith("admin_unjail"))
{
try
{
player = st.nextToken();
final L2PcInstance playerObj = L2World.getInstance().getPlayer(player);
if (playerObj != null)
{
playerObj.setInJail(false, 0);
activeChar.sendMessage("Character " + player + " removed from jail.");
}
else
{
unjailOfflinePlayer(activeChar, player);
}
}
catch (final NoSuchElementException nsee)
{
activeChar.sendMessage("Specify a character name.");
}
catch (final Exception e)
{
if (Config.DEBUG)
{
e.printStackTrace();
}
}
}
GMAudit.auditGMAction(activeChar.getName(), command, player, "");
return true;
}
private void jailOfflinePlayer(L2PcInstance activeChar, String name, int delay)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, in_jail=?, jail_timer=? WHERE char_name=?"))
{
statement.setInt(1, -114356);
statement.setInt(2, -249645);
statement.setInt(3, -2984);
statement.setInt(4, 1);
statement.setLong(5, delay * 60000);
statement.setString(6, name);
statement.execute();
final int count = statement.getUpdateCount();
if (count == 0)
{
activeChar.sendMessage("Character not found!");
}
else
{
activeChar.sendMessage("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
}
}
catch (final SQLException se)
{
activeChar.sendMessage("SQLException while jailing player");
if (Config.DEBUG)
{
se.printStackTrace();
}
}
}
private void unjailOfflinePlayer(L2PcInstance activeChar, String name)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, in_jail=?, jail_timer=? WHERE char_name=?"))
{
statement.setInt(1, 17836);
statement.setInt(2, 170178);
statement.setInt(3, -3507);
statement.setInt(4, 0);
statement.setLong(5, 0);
statement.setString(6, name);
statement.execute();
final int count = statement.getUpdateCount();
if (count == 0)
{
activeChar.sendMessage("Character not found!");
}
else
{
activeChar.sendMessage("Character " + name + " removed from jail.");
}
}
catch (final SQLException se)
{
activeChar.sendMessage("SQLException while jailing player.");
if (Config.DEBUG)
{
se.printStackTrace();
}
}
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,145 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - admin_banchat = Imposes a chat ban on the specified player/target. - admin_unbanchat = Removes any chat ban on the specified player/target. Uses: admin_banchat [<player_name>] [<ban_duration>] admin_unbanchat [<player_name>] If <player_name> is not
* specified, the current target player is used.
* @version $Revision: 1.1.6.3 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminBanChat implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminBan.class.getName());
private static String[] _adminCommands =
{
"admin_banchat",
"admin_unbanchat"
};
private static final int REQUIRED_LEVEL = Config.GM_BAN_CHAT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel())))
{
return false;
}
}
final String[] cmdParams = command.split(" ");
long banLength = -1;
L2Object targetObject = null;
L2PcInstance targetPlayer = null;
if (cmdParams.length > 1)
{
targetPlayer = L2World.getInstance().getPlayer(cmdParams[1]);
if (cmdParams.length > 2)
{
try
{
banLength = Integer.parseInt(cmdParams[2]) * 60000;
}
catch (final NumberFormatException nfe)
{
}
}
}
else
{
if (activeChar.getTarget() != null)
{
targetObject = activeChar.getTarget();
if ((targetObject != null) && (targetObject instanceof L2PcInstance))
{
targetPlayer = (L2PcInstance) targetObject;
}
}
}
if (targetPlayer == null)
{
activeChar.sendMessage("Incorrect parameter or target.");
return false;
}
if (command.startsWith("admin_banchat"))
{
String banLengthStr = "";
if (banLength > -1)
{
targetPlayer.setChatUnbanTask(ThreadPoolManager.getInstance().scheduleGeneral(new SchedChatUnban(targetPlayer, activeChar), banLength));
banLengthStr = " for " + banLength + " seconds.";
}
activeChar.sendMessage(targetPlayer.getName() + " is now chat banned" + banLengthStr + ".");
targetPlayer.setChatBanned(true);
}
else if (command.startsWith("admin_unbanchat"))
{
activeChar.sendMessage(targetPlayer.getName() + "'s chat ban has now been lifted.");
targetPlayer.setChatBanned(false);
}
GMAudit.auditGMAction(activeChar.getName(), command, targetPlayer.getName(), "");
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private class SchedChatUnban implements Runnable
{
L2PcInstance _player;
@SuppressWarnings("unused")
L2PcInstance _banner;
protected SchedChatUnban(L2PcInstance player, L2PcInstance banner)
{
_player = player;
_banner = banner;
}
@Override
public void run()
{
_player.setChatBanned(false);
}
}
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.io.File;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.cache.CrestCache;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Layanere
*/
public class AdminCache implements IAdminCommandHandler
{
private static final int REQUIRED_LEVEL = Config.GM_CACHE;
private static String[] _adminCommands =
{
"admin_cache_htm_rebuild",
"admin_cache_htm_reload",
"admin_cache_reload_path",
"admin_cache_reload_file",
"admin_cache_crest_rebuild",
"admin_cache_crest_reload",
"admin_cache_crest_fix"
};
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_cache_htm_rebuild") || command.equals("admin_cache_htm_reload"))
{
HtmCache.getInstance().reload(Config.DATAPACK_ROOT);
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " MB on " + HtmCache.getInstance().getLoadedFiles() + " file(s) loaded.");
}
else if (command.startsWith("admin_cache_reload_path "))
{
final String path = command.split(" ")[1];
HtmCache.getInstance().reloadPath(new File(Config.DATAPACK_ROOT, path));
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " MB in " + HtmCache.getInstance().getLoadedFiles() + " file(s) loaded.");
}
else if (command.startsWith("admin_cache_reload_file "))
{
final String path = command.split(" ")[1];
if (HtmCache.getInstance().loadFile(new File(Config.DATAPACK_ROOT, path)) != null)
{
activeChar.sendMessage("Cache[HTML]: file was loaded");
}
else
{
activeChar.sendMessage("Cache[HTML]: file can't be loaded");
}
}
else if (command.startsWith("admin_cache_crest_rebuild") || command.startsWith("admin_cache_crest_reload"))
{
CrestCache.getInstance().reload();
activeChar.sendMessage("Cache[Crest]: " + String.format("%.3f", CrestCache.getInstance().getMemoryUsage()) + " megabytes on " + CrestCache.getInstance().getLoadedFiles() + " files loaded");
}
else if (command.startsWith("admin_cache_crest_fix"))
{
CrestCache.getInstance().convertOldPledgeFiles();
activeChar.sendMessage("Cache[Crest]: crests fixed");
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
return true;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,144 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.l2jmobius.Config;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - changelvl = change a character's access level Can be used for character ban (as opposed to regular //ban that affects accounts) or to grant mod/GM privileges ingame
* @version $Revision: 1.1.2.2.2.3 $ $Date: 2005/04/11 10:06:00 $
*/
public class AdminChangeAccessLevel implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_changelvl"
};
private static final int REQUIRED_LEVEL = Config.GM_ACCESSLEVEL;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
handleChangeLevel(command, activeChar);
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
/**
* If no character name is specified, tries to change GM's target access level. Else if a character name is provided, will try to reach it either from L2World or from a database connection.
* @param command
* @param activeChar
*/
private void handleChangeLevel(String command, L2PcInstance activeChar)
{
final String[] parts = command.split(" ");
if (parts.length == 2)
{
try
{
final int lvl = Integer.parseInt(parts[1]);
if (activeChar.getTarget() instanceof L2PcInstance)
{
((L2PcInstance) activeChar.getTarget()).setAccessLevel(lvl);
if (lvl < 0)
{
((L2PcInstance) activeChar.getTarget()).logout();
}
}
else
{
activeChar.sendMessage("Incorrect Target.");
}
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //changelvl <target_new_level> | <player_name> <new_level>");
}
}
else if (parts.length == 3)
{
final String name = parts[1];
final int lvl = Integer.parseInt(parts[2]);
final L2PcInstance player = L2World.getInstance().getPlayer(name);
if (player != null)
{
player.setAccessLevel(lvl);
if (lvl < 0)
{
player.logout();
}
}
else
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
{
statement.setInt(1, lvl);
statement.setString(2, name);
statement.execute();
final int count = statement.getUpdateCount();
if (count == 0)
{
activeChar.sendMessage("Character not found or access level unaltered.");
}
else
{
activeChar.sendMessage("Character access level updated.");
}
}
catch (final SQLException se)
{
activeChar.sendMessage("Error while changing character's access level.");
if (Config.DEBUG)
{
se.printStackTrace();
}
}
}
}
}
}

View File

@@ -0,0 +1,201 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.templates.L2Item;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - itemcreate = show menu - create_item id [num] = creates num items with respective id, if num is not specified num = 1 - giveitem name id [num] = gives num items to specified player name with respective id, if num is not specified num = 1
* @version $Revision: 1.2.2.2.2.3 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminCreateItem implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_itemcreate",
"admin_create_item",
"admin_giveitem"
};
private static final int REQUIRED_LEVEL = Config.GM_CREATE_ITEM;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_itemcreate"))
{
AdminHelpPage.showHelpPage(activeChar, "itemcreation.htm");
}
else if (command.startsWith("admin_create_item"))
{
try
{
final String val = command.substring(17);
final StringTokenizer st = new StringTokenizer(val);
if (st.countTokens() == 2)
{
final String id = st.nextToken();
final int idval = Integer.parseInt(id);
final String num = st.nextToken();
final int numval = Integer.parseInt(num);
createItem(activeChar, activeChar, idval, numval);
}
else if (st.countTokens() == 1)
{
final String id = st.nextToken();
final int idval = Integer.parseInt(id);
createItem(activeChar, activeChar, idval, 1);
}
else
{
AdminHelpPage.showHelpPage(activeChar, "itemcreation.htm");
}
}
catch (final StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error while creating item.");
}
catch (final NumberFormatException nfe)
{
activeChar.sendMessage("Wrong number entered.");
}
GMAudit.auditGMAction(activeChar.getName(), command, "no-target", "");
}
else if (command.startsWith("admin_giveitem"))
{
try
{
final String val = command.substring(14);
final StringTokenizer st = new StringTokenizer(val);
if (st.countTokens() == 3)
{
final L2PcInstance target = L2World.getInstance().getPlayer(st.nextToken());
if (target == null)
{
activeChar.sendMessage("Target is not online.");
return false;
}
final String id = st.nextToken();
final int idval = Integer.parseInt(id);
final String num = st.nextToken();
final int numval = Integer.parseInt(num);
createItem(activeChar, target, idval, numval);
GMAudit.auditGMAction(activeChar.getName(), command, target.getName(), "");
}
else if (st.countTokens() == 2)
{
final L2PcInstance target = L2World.getInstance().getPlayer(st.nextToken());
if (target == null)
{
activeChar.sendMessage("Target is not online.");
return false;
}
final String id = st.nextToken();
final int idval = Integer.parseInt(id);
createItem(activeChar, target, idval, 1);
GMAudit.auditGMAction(activeChar.getName(), command, target.getName(), "");
}
}
catch (final StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error while creating item.");
}
catch (final NumberFormatException nfe)
{
activeChar.sendMessage("Wrong number entered.");
}
}
return true;
}
private void createItem(L2PcInstance activeChar, L2PcInstance target, int id, int num)
{
if (num > 20)
{
final L2Item template = ItemTable.getInstance().getTemplate(id);
if (!template.isStackable())
{
activeChar.sendMessage("This item does not stack - Creation aborted.");
return;
}
}
target.getInventory().addItem("Admin", id, num, target, null);
final ItemList il = new ItemList(target, true);
target.sendPacket(il);
activeChar.sendMessage("You have spawned " + num + " item(s) number " + id + " in " + target.getName() + "'s inventory.");
if (activeChar != target)
{
target.sendMessage("An Admin has spawned " + num + " item(s) number " + id + " in your inventory.");
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Item Creation Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_help itemcreation.htm\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<table width=270><tr><td>Item Creation Complete.<br></td></tr></table>");
replyMSG.append("<table width=270><tr><td>You have spawned " + num + " item(s) number in " + target.getName() + "'s inventory.</td></tr></table>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - delete = deletes target
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
*/
public class AdminDelete implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminDelete.class.getName());
private static String[] _adminCommands =
{
"admin_delete"
};
private static final int REQUIRED_LEVEL = Config.GM_NPC_EDIT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_delete"))
{
handleDelete(activeChar);
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
// TODO: add possibility to delete any L2Object (except L2PcInstance)
private void handleDelete(L2PcInstance activeChar)
{
final L2Object obj = activeChar.getTarget();
if ((obj != null) && (obj instanceof L2NpcInstance))
{
final L2NpcInstance target = (L2NpcInstance) obj;
target.deleteMe();
final L2Spawn spawn = target.getSpawn();
if (spawn != null)
{
spawn.stopRespawn();
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getNpcid()))
{
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
}
else
{
SpawnTable.getInstance().deleteSpawn(spawn, true);
}
}
activeChar.sendMessage("Deleted " + target.getName() + " from " + target.getObjectId() + ".");
}
else
{
activeChar.sendMessage("Incorrect target.");
}
}
}

View File

@@ -0,0 +1,93 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - character_disconnect = disconnects target player
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:00 $
*/
public class AdminDisconnect implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_character_disconnect"
};
private static final int REQUIRED_LEVEL = Config.GM_KICK;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_character_disconnect"))
{
disconnectCharacter(activeChar);
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
return true;
}
private void disconnectCharacter(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return;
}
if (player.getObjectId() == activeChar.getObjectId())
{
activeChar.sendMessage("You cannot disconnect your own character.");
}
else
{
activeChar.sendMessage("Character " + player.getName() + " has been disconnected from server.");
player.logout();
}
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,170 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.DoorTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
/**
* This class handles following admin commands: - open1 = open coloseum door 24190001 - open2 = open coloseum door 24190002 - open3 = open coloseum door 24190003 - open4 = open coloseum door 24190004 - openall = open all coloseum door - close1 = close coloseum door 24190001 - close2 = close coloseum
* door 24190002 - close3 = close coloseum door 24190003 - close4 = close coloseum door 24190004 - closeall = close all coloseum door - open = open selected door - close = close selected door
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminDoorControl implements IAdminCommandHandler
{
private static final int REQUIRED_LEVEL = Config.GM_DOOR;
private static DoorTable _doorTable;
private static String[] _adminCommands =
{
"admin_open",
"admin_close",
"admin_openall",
"admin_closeall"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
_doorTable = DoorTable.getInstance();
try
{
if (command.startsWith("admin_open "))
{
final int doorId = Integer.parseInt(command.substring(11));
if (_doorTable.getDoor(doorId) != null)
{
_doorTable.getDoor(doorId).openMe();
}
else
{
for (final Castle castle : CastleManager.getInstance().getCastles())
{
if (castle.getDoor(doorId) != null)
{
castle.getDoor(doorId).openMe();
}
}
}
}
else if (command.startsWith("admin_close "))
{
final int doorId = Integer.parseInt(command.substring(12));
if (_doorTable.getDoor(doorId) != null)
{
_doorTable.getDoor(doorId).closeMe();
}
else
{
for (final Castle castle : CastleManager.getInstance().getCastles())
{
if (castle.getDoor(doorId) != null)
{
castle.getDoor(doorId).closeMe();
}
}
}
}
else if (command.equals("admin_closeall"))
{
for (final L2DoorInstance door : _doorTable.getDoors())
{
door.closeMe();
}
for (final Castle castle : CastleManager.getInstance().getCastles())
{
for (final L2DoorInstance door : castle.getDoors())
{
door.closeMe();
}
}
}
else if (command.equals("admin_openall"))
{
for (final L2DoorInstance door : _doorTable.getDoors())
{
door.openMe();
}
for (final Castle castle : CastleManager.getInstance().getCastles())
{
for (final L2DoorInstance door : castle.getDoors())
{
door.openMe();
}
}
}
else if (command.equals("admin_open"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2DoorInstance)
{
((L2DoorInstance) target).openMe();
}
else
{
activeChar.sendMessage("Incorrect target.");
}
}
else if (command.equals("admin_close"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2DoorInstance)
{
((L2DoorInstance) target).closeMe();
}
else
{
activeChar.sendMessage("Incorrect target.");
}
}
}
catch (final Exception e)
{
e.printStackTrace();
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,908 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.Collection;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.datatables.CharNameTable;
import com.l2jmobius.gameserver.datatables.ClanTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import com.l2jmobius.gameserver.util.Util;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - edit_character - current_player - character_list - character_info - show_characters - find_character - find_ip - find_account - rec - nokarma - setkarma - settitle - changename - setsex - setclass - fullfood - save_modifications
* @version $Revision: 1.3.2.1.2.10 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminEditChar implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminEditChar.class.getName());
private static String[] _adminCommands =
{
"admin_edit_character",
"admin_current_player",
"admin_nokarma", // this is to remove karma from selected char...
"admin_setkarma", // sets karma of target char to any amount. //setkarma <karma>
"admin_character_list", // same as character_info, kept for compatibility purposes
"admin_character_info", // given a player name, displays an information window
"admin_show_characters", // list of characters
"admin_find_character", // find a player by his name or a part of it (case-insensitive)
"admin_find_ip", // find all the player connections from a given IPv4Filter number
"admin_find_account", // list all the characters from an account (useful for GMs w/o DB access)
"admin_save_modifications", // consider it deprecated...
"admin_rec", // gives recommendation points
"admin_settitle", // changes char title
"admin_changename", // changes char name
"admin_setsex", // changes characters' sex
"admin_setcolor", // change charnames' color display
"admin_setclass", // changes chars' classId
"admin_fullfood" // fulfills a pet's food bar
};
private static final int REQUIRED_LEVEL = Config.GM_CHAR_EDIT;
private static final int REQUIRED_LEVEL2 = Config.GM_CHAR_EDIT_OTHER;
private static final int REQUIRED_LEVEL_VIEW = Config.GM_CHAR_VIEW;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!((checkLevel(activeChar.getAccessLevel()) || checkLevel2(activeChar.getAccessLevel())) && activeChar.isGM()))
{
return false;
}
}
GMAudit.auditGMAction(activeChar.getName(), command, (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target", "");
if (command.equals("admin_current_player"))
{
showCharacterInfo(activeChar, null);
}
else if (command.startsWith("admin_character_list") || command.startsWith("admin_character_info"))
{
try
{
final String val = command.substring(21);
final L2PcInstance target = L2World.getInstance().getPlayer(val);
if (target != null)
{
showCharacterInfo(activeChar, target);
}
else
{
activeChar.sendMessage("Character does not exist.");
}
}
catch (final StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Usage: //character_info <player_name>");
}
}
else if (command.startsWith("admin_show_characters"))
{
try
{
final String val = command.substring(22);
final int page = Integer.parseInt(val);
listCharacters(activeChar, page);
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty page number
activeChar.sendMessage("Usage: //show_characters <page_number>");
}
}
else if (command.startsWith("admin_find_character"))
{
try
{
final String val = command.substring(21);
findCharacter(activeChar, val);
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty character name
activeChar.sendMessage("Usage: //find_character <character_name>");
listCharacters(activeChar, 0);
}
}
else if (command.startsWith("admin_find_ip"))
{
try
{
final String val = command.substring(14);
findCharactersPerIp(activeChar, val);
}
catch (final Exception e)
{
// Case of empty or malformed IP number
activeChar.sendMessage("Usage: //find_ip <www.xxx.yyy.zzz>");
listCharacters(activeChar, 0);
}
}
else if (command.startsWith("admin_find_account"))
{
try
{
final String val = command.substring(19);
findCharactersPerAccount(activeChar, val);
}
catch (final Exception e)
{
// Case of empty or malformed player name
activeChar.sendMessage("Usage: //find_account <player_name>");
listCharacters(activeChar, 0);
}
}
else if (command.equals("admin_edit_character"))
{
editCharacter(activeChar);
}
else if (command.equals("admin_nokarma"))
{
setTargetKarma(activeChar, 0);
}
else if (command.startsWith("admin_setkarma"))
{
try
{
final String val = command.substring(15);
final int karma = Integer.parseInt(val);
if ((activeChar == activeChar.getTarget()) || (activeChar.getAccessLevel() >= REQUIRED_LEVEL2))
{
GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
}
setTargetKarma(activeChar, karma);
}
catch (final StringIndexOutOfBoundsException e)
{
if (Config.DEVELOPER)
{
System.out.println("Set karma error: " + e);
}
activeChar.sendMessage("Usage: //setkarma <new_karma_value>");
}
}
else if (command.startsWith("admin_save_modifications"))
{
try
{
final String val = command.substring(24);
if ((activeChar == activeChar.getTarget()) || (activeChar.getAccessLevel() >= REQUIRED_LEVEL2))
{
GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
}
adminModifyCharacter(activeChar, val);
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty character name
activeChar.sendMessage("Error while modifying character.");
listCharacters(activeChar, 0);
}
}
else if (command.startsWith("admin_rec"))
{
try
{
final String val = command.substring(10);
final int recVal = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if ((activeChar != target) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return false;
}
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
player.setRecomHave(recVal);
player.sendMessage("You have been recommended by a GM");
player.broadcastUserInfo();
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //rec number");
}
}
else if (command.startsWith("admin_setclass"))
{
try
{
if (command.equals("admin_setclass"))
{
AdminHelpPage.showHelpPage(activeChar, "charclasses.htm");
return true;
}
final String val = command.substring(15);
final int classidval = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if ((activeChar != target) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return false;
}
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
boolean valid = false;
for (final ClassId classid : ClassId.values())
{
if (classidval == classid.getId())
{
valid = true;
}
}
if (valid && (player.getClassId().getId() != classidval))
{
player.setClassId(classidval);
if (!player.isSubClassActive())
{
player.setBaseClass(classidval);
}
final String newclass = player.getTemplate().className;
player.store();
player.sendMessage("A GM changed your class to " + newclass);
player.broadcastUserInfo();
activeChar.sendMessage(player.getName() + " is a " + newclass);
}
}
catch (final StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Usage: //setclass <valid_new_classid>");
}
}
else if (command.startsWith("admin_settitle"))
{
try
{
final String val = command.substring(15);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if ((activeChar != target) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return false;
}
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
player.setTitle(val);
player.sendMessage("Your title has been changed by a GM.");
player.broadcastTitleInfo();
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty character title
activeChar.sendMessage("You need to specify the new title.");
}
}
else if (command.startsWith("admin_changename"))
{
try
{
final String val = command.substring(17);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if ((activeChar != target) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return false;
}
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
if (player.getName().equals(val))
{
activeChar.sendMessage("This name is already used by this player.");
return false;
}
if (CharNameTable.getInstance().doesCharNameExist(val))
{
activeChar.sendMessage("Warning, name " + val + " already exists.");
return false;
}
L2World.getInstance().removeFromAllPlayers(player);
player.setName(val);
player.store();
L2World.getInstance().addToAllPlayers(player);
player.sendMessage("Your name has been changed by a GM.");
player.broadcastUserInfo();
if (player.getClan() != null)
{
player.getClan().broadcastToOnlineMembers(new PledgeShowMemberListAll(player.getClan(), player));
}
player.leaveParty();
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty character name
activeChar.sendMessage("Usage: //setname new_name_for_target");
}
}
else if (command.startsWith("admin_setsex"))
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if ((activeChar != target) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return false;
}
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
player.sendMessage("Your gender has been changed by a GM.");
player.broadcastUserInfo();
player.decayMe();
player.spawnMe(player.getX(), player.getY(), player.getZ());
}
else if (command.startsWith("admin_setcolor"))
{
try
{
final String val = command.substring(15);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if ((activeChar != target) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return false;
}
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
player.getAppearance().setNameColor(Integer.decode("0x" + val));
player.sendMessage("Your name color has been changed by a GM.");
player.broadcastUserInfo();
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty color
activeChar.sendMessage("You need to specify the new color.");
}
}
else if (command.startsWith("admin_fullfood"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PetInstance)
{
final L2PetInstance targetPet = (L2PetInstance) target;
targetPet.setCurrentFed(targetPet.getMaxFed());
}
else
{
activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private boolean checkLevel2(int level)
{
return (level >= REQUIRED_LEVEL_VIEW);
}
private void listCharacters(L2PcInstance activeChar, int page)
{
final Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers();
final L2PcInstance[] players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
final int MaxCharactersPerPage = 20;
int MaxPages = players.length / MaxCharactersPerPage;
if (players.length > (MaxCharactersPerPage * MaxPages))
{
MaxPages++;
}
// Check if number of users changed
if (page > MaxPages)
{
page = MaxPages;
}
final int CharactersStart = MaxCharactersPerPage * page;
int CharactersEnd = players.length;
if ((CharactersEnd - CharactersStart) > MaxCharactersPerPage)
{
CharactersEnd = CharactersStart + MaxCharactersPerPage;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile("data/html/admin/charlist.htm");
final TextBuilder replyMSG = new TextBuilder();
for (int x = 0; x < MaxPages; x++)
{
final int pagenr = x + 1;
replyMSG.append("<center><a action=\"bypass -h admin_show_characters " + x + "\">Page " + pagenr + "</a></center>");
}
adminReply.replace("%pages%", replyMSG.toString());
replyMSG.clear();
for (int i = CharactersStart; i < CharactersEnd; i++)
{
// Add player info into new Table row
replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_character_info " + players[i].getName() + "\">" + players[i].getName() + "</a></td><td width=110>" + players[i].getTemplate().className + "</td><td width=40>" + players[i].getLevel() + "</td></tr>");
}
adminReply.replace("%players%", replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void showCharacterInfo(L2PcInstance activeChar, L2PcInstance player)
{
if (player == null)
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return;
}
}
else
{
activeChar.setTarget(player);
}
gatherCharacterInfo(activeChar, player, "charinfo.htm");
}
/**
* @param activeChar
* @param player
* @param filename
*/
private void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename)
{
String ip = "N/A";
String account = "N/A";
try
{
final String clientInfo = player.getClient().toString();
account = clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: "));
ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]"));
}
catch (final Exception e)
{
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile("data/html/admin/" + filename);
adminReply.replace("%name%", player.getName());
adminReply.replace("%level%", String.valueOf(player.getLevel()));
adminReply.replace("%clan%", String.valueOf(ClanTable.getInstance().getClan(player.getClanId())));
adminReply.replace("%xp%", String.valueOf(player.getExp()));
adminReply.replace("%sp%", String.valueOf(player.getSp()));
adminReply.replace("%class%", player.getTemplate().className);
adminReply.replace("%ordinal%", String.valueOf(player.getClassId().ordinal()));
adminReply.replace("%classid%", String.valueOf(player.getClassId()));
adminReply.replace("%x%", String.valueOf(player.getX()));
adminReply.replace("%y%", String.valueOf(player.getY()));
adminReply.replace("%z%", String.valueOf(player.getZ()));
adminReply.replace("%currenthp%", String.valueOf((int) player.getCurrentHp()));
adminReply.replace("%maxhp%", String.valueOf(player.getMaxHp()));
adminReply.replace("%karma%", String.valueOf(player.getKarma()));
adminReply.replace("%currentmp%", String.valueOf((int) player.getCurrentMp()));
adminReply.replace("%maxmp%", String.valueOf(player.getMaxMp()));
adminReply.replace("%pvpflag%", String.valueOf(player.getPvpFlag()));
adminReply.replace("%currentcp%", String.valueOf((int) player.getCurrentCp()));
adminReply.replace("%maxcp%", String.valueOf(player.getMaxCp()));
adminReply.replace("%pvpkills%", String.valueOf(player.getPvpKills()));
adminReply.replace("%pkkills%", String.valueOf(player.getPkKills()));
adminReply.replace("%currentload%", String.valueOf(player.getCurrentLoad()));
adminReply.replace("%maxload%", String.valueOf(player.getMaxLoad()));
adminReply.replace("%percent%", String.valueOf(Util.roundTo(((float) player.getCurrentLoad() / (float) player.getMaxLoad()) * 100, 2)));
adminReply.replace("%patk%", String.valueOf(player.getPAtk(null)));
adminReply.replace("%matk%", String.valueOf(player.getMAtk(null, null)));
adminReply.replace("%pdef%", String.valueOf(player.getPDef(null)));
adminReply.replace("%mdef%", String.valueOf(player.getMDef(null, null)));
adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy()));
adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null)));
adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null)));
adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed()));
adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd()));
adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd()));
adminReply.replace("%access%", String.valueOf(player.getAccessLevel()));
adminReply.replace("%account%", account);
adminReply.replace("%ip%", ip);
activeChar.sendPacket(adminReply);
}
private void setTargetKarma(L2PcInstance activeChar, int newKarma)
{
// function to change karma of selected char
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return;
}
if (newKarma >= 0)
{
// for display
final int oldKarma = player.getKarma();
// update karma
player.setKarma(newKarma);
// Common character information
player.sendMessage("Admin has changed your karma from " + oldKarma + " to " + newKarma + ".");
// Admin information
activeChar.sendMessage("Successfully Changed karma for " + player.getName() + " from (" + oldKarma + ") to (" + newKarma + ").");
if (Config.DEBUG)
{
_log.fine("[SET KARMA] [GM]" + activeChar.getName() + " Changed karma for " + player.getName() + " from (" + oldKarma + ") to (" + newKarma + ").");
}
}
else
{
// tell admin of mistake
activeChar.sendMessage("You must enter a value for karma equal to 0 or greater.");
if (Config.DEBUG)
{
_log.fine("[SET KARMA] ERROR: [GM]" + activeChar.getName() + " entered an incorrect value for new karma: " + newKarma + " for " + player.getName() + ".");
}
}
}
private void adminModifyCharacter(L2PcInstance activeChar, String modifications)
{
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2PcInstance))
{
return;
}
final L2PcInstance player = (L2PcInstance) target;
final StringTokenizer st = new StringTokenizer(modifications);
if (st.countTokens() != 6)
{
editCharacter(player);
activeChar.sendMessage("Changes have not been saved. Please set values for all stats.");
return;
}
final String hp = st.nextToken();
final String mp = st.nextToken();
final String cp = st.nextToken();
final String pvpflag = st.nextToken();
final String pvpkills = st.nextToken();
final String pkkills = st.nextToken();
final int hpval = Integer.parseInt(hp);
final int mpval = Integer.parseInt(mp);
final int cpval = Integer.parseInt(cp);
final int pvpflagval = Integer.parseInt(pvpflag);
final int pvpkillsval = Integer.parseInt(pvpkills);
final int pkkillsval = Integer.parseInt(pkkills);
// Common character information
player.sendMessage("Admin has changed your stats." + " HP: " + hpval + " MP: " + mpval + " CP: " + cpval + " PvP Flag: " + pvpflagval + " PvP/PK " + pvpkillsval + "/" + pkkillsval);
player.setCurrentHp(hpval);
player.setCurrentMp(mpval);
player.setCurrentCp(cpval);
player.setPvpFlag(pvpflagval);
player.setPvpKills(pvpkillsval);
player.setPkKills(pkkillsval);
// Save the changed parameters to the database.
player.store();
final StatusUpdate su = new StatusUpdate(player.getObjectId());
su.addAttribute(StatusUpdate.CUR_HP, hpval);
su.addAttribute(StatusUpdate.MAX_HP, player.getMaxHp());
su.addAttribute(StatusUpdate.CUR_MP, mpval);
su.addAttribute(StatusUpdate.MAX_MP, player.getMaxMp());
su.addAttribute(StatusUpdate.CUR_CP, cpval);
su.addAttribute(StatusUpdate.MAX_CP, player.getMaxCp());
player.sendPacket(su);
// Admin information
player.sendMessage("Changed stats of " + player.getName() + "." + " HP: " + hpval + " MP: " + mpval + " CP: " + cpval + " PvP: " + pvpflagval + " / " + pvpkillsval);
if (Config.DEBUG)
{
_log.fine("[GM]" + activeChar.getName() + " changed stats of " + player.getName() + ". " + " HP: " + hpval + " MP: " + mpval + " CP: " + cpval + " PvP: " + pvpflagval + " / " + pvpkillsval);
}
showCharacterInfo(activeChar, null); // Back to start
player.broadcastPacket(new CharInfo(player));
player.sendPacket(new UserInfo(player));
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
player.decayMe();
player.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
}
private void editCharacter(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2PcInstance))
{
return;
}
final L2PcInstance player = (L2PcInstance) target;
gatherCharacterInfo(activeChar, player, "charedit.htm");
}
/**
* @param activeChar
* @param CharacterToFind
*/
private void findCharacter(L2PcInstance activeChar, String CharacterToFind)
{
int CharactersFound = 0;
String name;
final Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers();
final L2PcInstance[] players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile("data/html/admin/charfind.htm");
final TextBuilder replyMSG = new TextBuilder();
for (final L2PcInstance player : players)
{ // Add player info into new Table row
name = player.getName();
if (name.toLowerCase().contains(CharacterToFind.toLowerCase()))
{
CharactersFound = CharactersFound + 1;
replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_character_list " + name + "\">" + name + "</a></td><td width=110>" + player.getTemplate().className + "</td><td width=40>" + player.getLevel() + "</td></tr>");
}
if (CharactersFound > 20)
{
break;
}
}
adminReply.replace("%results%", replyMSG.toString());
replyMSG.clear();
if (CharactersFound == 0)
{
replyMSG.append("s. Please try again.");
}
else if (CharactersFound > 20)
{
adminReply.replace("%number%", " more than 20");
replyMSG.append("s.<br>Please refine your search to see all of the results.");
}
else if (CharactersFound == 1)
{
replyMSG.append(".");
}
else
{
replyMSG.append("s.");
}
adminReply.replace("%number%", String.valueOf(CharactersFound));
adminReply.replace("%end%", replyMSG.toString());
activeChar.sendPacket(adminReply);
}
/**
* @param activeChar
* @param IpAdress
* @throws IllegalArgumentException
*/
private void findCharactersPerIp(L2PcInstance activeChar, String IpAdress) throws IllegalArgumentException
{
boolean findDisconnected = false;
if (IpAdress.equals("disconnected"))
{
findDisconnected = true;
}
else
{
if (!IpAdress.matches("^(?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))$"))
{
throw new IllegalArgumentException("Malformed IPv4Filter number");
}
}
final Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers();
final L2PcInstance[] players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
int CharactersFound = 0;
L2GameClient client;
String name, ip = "0.0.0.0";
final TextBuilder replyMSG = new TextBuilder();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile("data/html/admin/ipfind.htm");
for (final L2PcInstance player : players)
{
client = player.getClient();
if (client.isDetached())
{
if (!findDisconnected)
{
continue;
}
}
else
{
if (findDisconnected)
{
continue;
}
ip = client.getConnection().getInetAddress().getHostAddress();
if (!ip.equals(IpAdress))
{
continue;
}
}
name = player.getName();
CharactersFound = CharactersFound + 1;
replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_character_list " + name + "\">" + name + "</a></td><td width=110>" + player.getTemplate().className + "</td><td width=40>" + player.getLevel() + "</td></tr>");
if (CharactersFound > 20)
{
break;
}
}
adminReply.replace("%results%", replyMSG.toString());
replyMSG.clear();
if (CharactersFound == 0)
{
replyMSG.append("s. Maybe they got d/c? :)");
}
else if (CharactersFound > 20)
{
adminReply.replace("%number%", " more than " + String.valueOf(CharactersFound));
replyMSG.append("s.<br>In order to avoid you a client crash I won't <br1>display results beyond the 20th character.");
}
else if (CharactersFound == 1)
{
replyMSG.append(".");
}
else
{
replyMSG.append("s.");
}
adminReply.replace("%ip%", ip);
adminReply.replace("%number%", String.valueOf(CharactersFound));
adminReply.replace("%end%", replyMSG.toString());
activeChar.sendPacket(adminReply);
}
/**
* @param activeChar
* @param characterName
* @throws IllegalArgumentException
*/
private void findCharactersPerAccount(L2PcInstance activeChar, String characterName) throws IllegalArgumentException
{
if (characterName.matches(Config.CNAME_TEMPLATE))
{
String account = null;
Map<Integer, String> chars;
final L2PcInstance player = L2World.getInstance().getPlayer(characterName);
if (player == null)
{
throw new IllegalArgumentException("Player doesn't exist");
}
chars = player.getAccountChars();
account = player.getAccountName();
final TextBuilder replyMSG = new TextBuilder();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile("data/html/admin/accountinfo.htm");
for (final String charname : chars.values())
{
replyMSG.append(charname + "<br1>");
}
adminReply.replace("%characters%", replyMSG.toString());
adminReply.replace("%account%", account);
adminReply.replace("%player%", characterName);
activeChar.sendPacket(adminReply);
}
else
{
throw new IllegalArgumentException("Malformed character name");
}
}
}

View File

@@ -0,0 +1,519 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.Collection;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Summon;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.network.serverpackets.StopMove;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
/**
* This class handles following admin commands: - invis / invisible = make yourself invisible - vis / visible = make yourself visible
*/
public class AdminEffects implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminDelete.class.getName());
private static String[] _adminCommands =
{
"admin_invis",
"admin_invisible",
"admin_vis",
"admin_visible",
"admin_earthquake",
"admin_bighead",
"admin_shrinkhead",
"admin_gmspeed",
"admin_unpara_all",
"admin_para_all",
"admin_unpara",
"admin_para",
"admin_polyself",
"admin_unpolyself",
"admin_clearteams",
"admin_setteam",
"admin_social",
"admin_effect"
};
private static final int REQUIRED_LEVEL = Config.GM_GODMODE;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
if (command.equals("admin_invis") || command.equals("admin_invisible"))
{
activeChar.getAppearance().setInvisible();
activeChar.broadcastUserInfo();
activeChar.decayMe();
activeChar.spawnMe();
}
else if (command.equals("admin_vis") || command.equals("admin_visible"))
{
activeChar.getAppearance().setVisible();
activeChar.broadcastUserInfo();
}
else if (command.startsWith("admin_earthquake"))
{
try
{
final String val1 = st.nextToken();
final int intensity = Integer.parseInt(val1);
final String val2 = st.nextToken();
final int duration = Integer.parseInt(val2);
final Earthquake eq = new Earthquake(activeChar.getX(), activeChar.getY(), activeChar.getZ(), intensity, duration);
activeChar.broadcastPacket(eq);
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_para"))
{
String type = "1";
try
{
type = st.nextToken();
}
catch (final Exception e)
{
}
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
if (type.equals("1"))
{
player.startAbnormalEffect((short) 0x0400);
}
else
{
player.startAbnormalEffect((short) 0x0800);
}
player.setIsParalyzed(true);
final StopMove sm = new StopMove(player);
player.sendPacket(sm);
player.broadcastPacket(sm);
}
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_unpara"))
{
String type = "1";
try
{
type = st.nextToken();
}
catch (final Exception e)
{
}
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
if (type.equals("1"))
{
player.stopAbnormalEffect((short) 0x0400);
}
else
{
player.stopAbnormalEffect((short) 0x0800);
}
player.setIsParalyzed(false);
}
}
catch (final Exception e)
{
}
}
else if (command.equals("admin_para_all"))
{
try
{
for (final L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
{
if (!player.isGM())
{
player.startAbnormalEffect((short) 0x0400);
player.setIsParalyzed(true);
final StopMove sm = new StopMove(player);
player.sendPacket(sm);
player.broadcastPacket(sm);
}
}
}
catch (final Exception e)
{
}
}
else if (command.equals("admin_unpara_all"))
{
try
{
for (final L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
{
player.stopAbnormalEffect((short) 0x0400);
player.setIsParalyzed(false);
}
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_bighead"))
{
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
player.startAbnormalEffect((short) 0x2000);
}
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_shrinkhead"))
{
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
player.stopAbnormalEffect((short) 0x2000);
}
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_gmspeed"))
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = activeChar.getFirstEffect(7029) != null;
if ((val == 0) && sendMessage)
{
activeChar.stopEffect(7029);
final SystemMessage sm = new SystemMessage(SystemMessage.EFFECT_S1_DISAPPEARED);
sm.addSkillName(7029);
activeChar.sendPacket(sm);
}
else if ((val >= 1) && (val <= 4))
{
final L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
gmSpeedSkill.getEffects(activeChar, activeChar);
activeChar.sendMessage("Use Super Haste Lv." + val + ".");
}
}
catch (final Exception e)
{
activeChar.sendMessage("Use //gmspeed value = [0...4].");
}
finally
{
activeChar.updateEffectIcons();
}
}
else if (command.startsWith("admin_polyself"))
{
try
{
final String id = st.nextToken();
activeChar.getPoly().setPolyInfo("npc", id);
activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);
final CharInfo info1 = new CharInfo(activeChar);
activeChar.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(activeChar);
activeChar.sendPacket(info2);
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_unpolyself"))
{
activeChar.getPoly().setPolyInfo(null, "1");
activeChar.decayMe();
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
final CharInfo info1 = new CharInfo(activeChar);
activeChar.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(activeChar);
activeChar.sendPacket(info2);
}
else if (command.equals("admin_clear_teams"))
{
try
{
for (final L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
{
player.setAuraColor(0);
player.broadcastUserInfo();
}
}
catch (final Exception e)
{
}
}
else if (command.startsWith("admin_setteam"))
{
final String val = st.nextToken();
final int teamVal = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
L2PcInstance player;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
return false;
}
player.setAuraColor(teamVal);
player.broadcastUserInfo();
}
else if (command.startsWith("admin_social"))
{
try
{
String target = null;
L2Object obj = activeChar.getTarget();
if (st.countTokens() == 2)
{
final int social = Integer.parseInt(st.nextToken());
target = st.nextToken();
if (target != null)
{
final L2PcInstance player = L2World.getInstance().getPlayer(target);
if (player != null)
{
if (performSocial(social, player, activeChar))
{
activeChar.sendMessage(player.getName() + " was affected by your request.");
}
}
else
{
try
{
final int radius = Integer.parseInt(target);
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
{
for (final L2Object object : objs)
{
if (activeChar.isInsideRadius(object, radius, false, false))
{
performSocial(social, object, activeChar);
}
}
}
activeChar.sendMessage(radius + " units radius affected by your request.");
}
catch (final NumberFormatException nbe)
{
activeChar.sendMessage("Incorrect parameter.");
}
}
}
}
else if (st.countTokens() == 1)
{
final int social = Integer.parseInt(st.nextToken());
if (obj == null)
{
obj = activeChar;
}
// if (obj != null)
// {
if (performSocial(social, obj, activeChar))
{
activeChar.sendMessage(obj.getName() + " was affected by your request.");
}
else
{
activeChar.sendMessage("Nothing happened.");
}
// }
// else
// {
// activeChar.sendMessage("Incorrect target.");
// }
}
else
{
activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
}
}
catch (final Exception e)
{
if (Config.DEBUG)
{
e.printStackTrace();
}
}
}
else if (command.startsWith("admin_effect"))
{
try
{
L2Object obj = activeChar.getTarget();
int level = 1, hittime = 1;
final int skill = Integer.parseInt(st.nextToken());
if (st.hasMoreTokens())
{
level = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
hittime = Integer.parseInt(st.nextToken());
}
if (obj == null)
{
obj = activeChar;
}
// if (obj != null)
// {
if (!(obj instanceof L2Character))
{
activeChar.sendMessage("Incorrect target.");
}
else
{
final L2Character target = (L2Character) obj;
target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
}
// }
// else
// {
// activeChar.sendMessage("Incorrect target.");
// }
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
}
}
return true;
}
private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
{
try
{
if (target instanceof L2Character)
{
if ((target instanceof L2Summon) || (target instanceof L2ChestInstance))
{
activeChar.sendMessage("Nothing happened.");
return false;
}
if ((target instanceof L2NpcInstance) && ((action < 1) || (action > 3)))
{
activeChar.sendMessage("Nothing happened.");
return false;
}
if ((target instanceof L2PcInstance) && ((action < 2) || (action > 16)))
{
activeChar.sendMessage("Nothing happened.");
return false;
}
final L2Character character = (L2Character) target;
character.broadcastPacket(new SocialAction(target.getObjectId(), action));
}
else
{
return false;
}
}
catch (final Exception e)
{
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,289 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.Inventory;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - enchant_armor
* @version $Revision: 1.3.2.1.2.10 $ $Date: 2005/08/24 21:06:06 $
*/
public class AdminEnchant implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminEnchant.class.getName());
private static String[] _adminCommands =
{
"admin_seteh", // 6
"admin_setec", // 10
"admin_seteg", // 9
"admin_setel", // 11
"admin_seteb", // 12
"admin_setew", // 7
"admin_setes", // 8
"admin_setle", // 1
"admin_setre", // 2
"admin_setlf", // 4
"admin_setrf", // 5
"admin_seten", // 3
"admin_setun", // 0
"admin_setba", // 13
"admin_enchant"
};
private static final int REQUIRED_LEVEL = Config.GM_ENCHANT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_enchant"))
{
showMainPage(activeChar);
}
else
{
int armorType = -1;
if (command.startsWith("admin_seteh"))
{
armorType = Inventory.PAPERDOLL_HEAD;
}
else if (command.startsWith("admin_setec"))
{
armorType = Inventory.PAPERDOLL_CHEST;
}
else if (command.startsWith("admin_seteg"))
{
armorType = Inventory.PAPERDOLL_GLOVES;
}
else if (command.startsWith("admin_seteb"))
{
armorType = Inventory.PAPERDOLL_FEET;
}
else if (command.startsWith("admin_setel"))
{
armorType = Inventory.PAPERDOLL_LEGS;
}
else if (command.startsWith("admin_setew"))
{
armorType = Inventory.PAPERDOLL_RHAND;
}
else if (command.startsWith("admin_setes"))
{
armorType = Inventory.PAPERDOLL_LHAND;
}
else if (command.startsWith("admin_setle"))
{
armorType = Inventory.PAPERDOLL_LEAR;
}
else if (command.startsWith("admin_setre"))
{
armorType = Inventory.PAPERDOLL_REAR;
}
else if (command.startsWith("admin_setlf"))
{
armorType = Inventory.PAPERDOLL_LFINGER;
}
else if (command.startsWith("admin_setrf"))
{
armorType = Inventory.PAPERDOLL_RFINGER;
}
else if (command.startsWith("admin_seten"))
{
armorType = Inventory.PAPERDOLL_NECK;
}
else if (command.startsWith("admin_setun"))
{
armorType = Inventory.PAPERDOLL_UNDER;
}
else if (command.startsWith("admin_setba"))
{
armorType = Inventory.PAPERDOLL_BACK;
}
if (armorType != -1)
{
try
{
final int ench = Integer.parseInt(command.substring(12));
// check value
if ((ench < 0) || (ench > 65535))
{
activeChar.sendMessage("You must set the enchant level to be between 0-65535.");
}
else
{
setEnchant(activeChar, ench, armorType);
}
}
catch (final StringIndexOutOfBoundsException e)
{
if (Config.DEVELOPER)
{
System.out.println("Set enchant error: " + e);
}
activeChar.sendMessage("Please specify a new enchant value.");
}
catch (final NumberFormatException e)
{
if (Config.DEVELOPER)
{
System.out.println("Set enchant error: " + e);
}
activeChar.sendMessage("Please specify a valid new enchant value.");
}
}
// show the enchant menu after an action
showMainPage(activeChar);
}
return true;
}
private void setEnchant(L2PcInstance activeChar, int ench, int armorType)
{
// get the target
L2Object target = activeChar.getTarget();
if (target == null)
{
target = activeChar;
}
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("Wrong target type.");
return;
}
// now we need to find the equipped weapon of the targeted character...
int curEnchant = 0; // display purposes only
L2ItemInstance itemInstance = null;
// only attempt to enchant if there is a weapon equipped
L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
if ((parmorInstance != null) && (parmorInstance.getEquipSlot() == armorType))
{
itemInstance = parmorInstance;
}
else
{
// for bows and double handed weapons
parmorInstance = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
if ((parmorInstance != null) && (parmorInstance.getEquipSlot() == Inventory.PAPERDOLL_LRHAND))
{
itemInstance = parmorInstance;
}
}
if (itemInstance != null)
{
curEnchant = itemInstance.getEnchantLevel();
// set enchant value
player.getInventory().unEquipItemInSlotAndRecord(armorType);
itemInstance.setEnchantLevel(ench);
player.getInventory().equipItemAndRecord(itemInstance);
// send packets
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(itemInstance);
player.sendPacket(iu);
player.broadcastPacket(new CharInfo(player));
player.sendPacket(new UserInfo(player));
// informations
activeChar.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
player.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
// log
GMAudit.auditGMAction(activeChar.getName(), "enchant", player.getName(), itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench);
}
}
public void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><table width=260><tr><td width=40>");
replyMSG.append("<button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</td><td width=180>");
replyMSG.append("<center>Enchant Equip</center>");
replyMSG.append("</td><td width=40>");
replyMSG.append("</td></tr></table></center><br>");
replyMSG.append("<center><table width=270><tr><td>");
replyMSG.append("<button value=\"Underwear\" action=\"bypass -h admin_setun $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Helmet\" action=\"bypass -h admin_seteh $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Cloak\" action=\"bypass -h admin_setba $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Mask\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Necklace\" action=\"bypass -h admin_seten $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
replyMSG.append("</center><center><table width=270><tr><td>");
replyMSG.append("<button value=\"Weapon\" action=\"bypass -h admin_setew $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Chest\" action=\"bypass -h admin_setec $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Shield\" action=\"bypass -h admin_setes $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Earring\" action=\"bypass -h admin_setre $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Earring\" action=\"bypass -h admin_setle $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
replyMSG.append("</center><center><table width=270><tr><td>");
replyMSG.append("<button value=\"Gloves\" action=\"bypass -h admin_seteg $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Leggings\" action=\"bypass -h admin_setel $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Boots\" action=\"bypass -h admin_seteb $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Ring\" action=\"bypass -h admin_setrf $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Ring\" action=\"bypass -h admin_setlf $menu_command\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
replyMSG.append("</center><br>");
replyMSG.append("<center>[Enchant 0-65535]</center>");
replyMSG.append("<center><edit var=\"menu_command\" width=100 height=15></center><br>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,831 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.L2Event;
import com.l2jmobius.gameserver.model.entity.TvTEvent;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - admin = shows menu
* @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminEventEngine implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_event",
"admin_event_new",
"admin_event_choose",
"admin_event_store",
"admin_event_set",
"admin_event_change_teams_number",
"admin_event_announce",
"admin_event_panel",
"admin_event_control_begin",
"admin_event_control_teleport",
"admin_add",
"admin_event_see",
"admin_event_del",
"admin_delete_buffer",
"admin_event_control_sit",
"admin_event_name",
"admin_event_control_kill",
"admin_event_control_res",
"admin_event_control_poly",
"admin_event_control_unpoly",
"admin_event_control_prize",
"admin_event_control_chatban",
"admin_event_control_finish",
"admin_tvt_abort"
};
private static final int REQUIRED_LEVEL = Config.GM_MENU;
private static String tempBuffer = "";
private static String tempName = "";
private static boolean npcsDeleted = false;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_event"))
{
showMainPage(activeChar);
}
else if (command.equals("admin_event_new"))
{
showNewEventPage(activeChar);
}
else if (command.startsWith("admin_add"))
{
tempBuffer += command.substring(10);
showNewEventPage(activeChar);
}
else if (command.startsWith("admin_event_see"))
{
final String eventName = command.substring(16);
try (FileInputStream file = new FileInputStream("data/events/" + eventName);
BufferedInputStream buffer = new BufferedInputStream(file);
DataInputStream in = new DataInputStream(buffer);
BufferedReader inbr = new BufferedReader(new InputStreamReader(in)))
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\">" + eventName + "</font><font color=\"FF0000\"> bY " + inbr.readLine() + "</font></center><br>");
replyMSG.append("<br>" + inbr.readLine());
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
catch (final Exception e)
{
System.out.println(e);
}
}
else if (command.startsWith("admin_event_del"))
{
final String eventName = command.substring(16);
final File file = new File("data/events/" + eventName);
file.delete();
showMainPage(activeChar);
}
else if (command.startsWith("admin_event_name"))
{
tempName += command.substring(17);
showNewEventPage(activeChar);
}
else if (command.equalsIgnoreCase("admin_delete_buffer"))
{
try
{
tempBuffer += tempBuffer.substring(0, tempBuffer.length() - 10);
showNewEventPage(activeChar);
}
catch (final Exception e)
{
tempBuffer = "";
}
}
else if (command.startsWith("admin_event_store"))
{
try (FileOutputStream file = new FileOutputStream("data/events/" + tempName);
PrintStream p = new PrintStream(file))
{
p.println(activeChar.getName());
p.println(tempBuffer);
}
catch (final Exception e)
{
System.out.println(e);
}
tempBuffer = "";
tempName = "";
showMainPage(activeChar);
}
else if (command.startsWith("admin_event_set"))
{
L2Event.eventName = command.substring(16);
showEventParameters(activeChar, 2);
}
else if (command.startsWith("admin_event_change_teams_number"))
{
showEventParameters(activeChar, Integer.parseInt(command.substring(32)));
}
else if (command.startsWith("admin_event_panel"))
{
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_begin"))
{
try
{
L2Event.active = true;
L2Event.players.clear();
L2Event.connectionLossData.clear();
for (int j = 0; j < L2Event.teamsNumber; j++)
{
final LinkedList<String> link = new LinkedList<>();
L2Event.players.put(j + 1, link);
}
int i = 0;
while (L2Event.participatingPlayers.size() > 0)
{
final String target = getMaxLeveledPlayer();
if (!target.isEmpty())
{
L2Event.players.get(i + 1).add(target);
i = (i + 1) % L2Event.teamsNumber;
}
else
{
break;
}
}
destroyEventNpcs();
npcsDeleted = true;
}
catch (final Exception e)
{
System.out.println(e);
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_teleport"))
{
final StringTokenizer st = new StringTokenizer(command.substring(29), "-");
while (st.hasMoreElements())
{
teleportTeam(activeChar, Integer.parseInt(st.nextToken()));
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_sit"))
{
final StringTokenizer st = new StringTokenizer(command.substring(24), "-");
while (st.hasMoreElements())
{
sitTeam(Integer.parseInt(st.nextToken()));
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_kill"))
{
final StringTokenizer st = new StringTokenizer(command.substring(25), "-");
while (st.hasMoreElements())
{
killTeam(activeChar, Integer.parseInt(st.nextToken()));
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_res"))
{
final StringTokenizer st = new StringTokenizer(command.substring(24), "-");
while (st.hasMoreElements())
{
resTeam(Integer.parseInt(st.nextToken()));
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_poly"))
{
final StringTokenizer st0 = new StringTokenizer(command.substring(25));
final StringTokenizer st = new StringTokenizer(st0.nextToken(), "-");
final String id = st0.nextToken();
while (st.hasMoreElements())
{
polyTeam(Integer.parseInt(st.nextToken()), id);
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_unpoly"))
{
final StringTokenizer st = new StringTokenizer(command.substring(27), "-");
while (st.hasMoreElements())
{
unpolyTeam(Integer.parseInt(st.nextToken()));
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_prize"))
{
final StringTokenizer st0 = new StringTokenizer(command.substring(26));
final StringTokenizer st = new StringTokenizer(st0.nextToken(), "-");
String n = st0.nextToken();
final StringTokenizer st1 = new StringTokenizer(n, "*");
n = st1.nextToken();
String type = "";
if (st1.hasMoreElements())
{
type = st1.nextToken();
}
final String id = st0.nextToken();
while (st.hasMoreElements())
{
regardTeam(activeChar, Integer.parseInt(st.nextToken()), Integer.parseInt(n), Integer.parseInt(id), type);
}
showEventControl(activeChar);
}
else if (command.startsWith("admin_event_control_finish"))
{
for (int i = 0; i < L2Event.teamsNumber; i++)
{
telePlayersBack(i + 1);
}
L2Event.eventName = "";
L2Event.teamsNumber = 0;
L2Event.names.clear();
L2Event.participatingPlayers.clear();
L2Event.players.clear();
L2Event.id = 12760;
L2Event.npcs.clear();
L2Event.active = false;
npcsDeleted = false;
}
else if (command.startsWith("admin_tvt_abort"))
{
if ((TvTEvent.getEventState() == TvTEvent.STARTED) || (TvTEvent.getEventState() == TvTEvent.REGISTER))
{
TvTEvent.setEventState(TvTEvent.ABORTED);
activeChar.sendMessage("TvT Event was successfully aborted.");
}
else
{
activeChar.sendMessage("TvT Event is not currently in progress.");
}
}
else if (command.startsWith("admin_event_announce"))
{
StringTokenizer st = new StringTokenizer(command.substring(21));
L2Event.id = Integer.parseInt(st.nextToken());
L2Event.teamsNumber = Integer.parseInt(st.nextToken());
String temp = " ";
String temp2 = "";
while (st.hasMoreElements())
{
temp += st.nextToken() + " ";
}
st = new StringTokenizer(temp, "-");
Integer i = 1;
while (st.hasMoreElements())
{
temp2 = st.nextToken();
if (!temp2.equals(" "))
{
L2Event.names.put(i, temp2.substring(1, temp2.length() - 1));
i++;
}
}
L2Event.participatingPlayers.clear();
muestraNpcConInfoAPlayers(activeChar, L2Event.id);
final PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
activeChar.sendPacket(_snd);
activeChar.broadcastPacket(_snd);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\">[ L2J EVENT ENGINE</font></center><br>");
replyMSG.append("<center>The event <font color=\"LEVEL\">" + L2Event.eventName + "</font> has been announced, now you can type //event_panel to see the event panel control</center><br>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private String showStoredEvents()
{
final File dir = new File("data/events");
final String[] files = dir.list();
String result = "";
if (files == null)
{
result = "No 'data/events' directory!";
return result;
}
for (final String file2 : files)
{
final File file = new File("data/events/" + file2);
result += "<font color=\"LEVEL\">" + file.getName() + " </font><br><button value=\"select\" action=\"bypass -h admin_event_set " + file.getName() + "\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><button value=\"ver\" action=\"bypass -h admin_event_see " + file.getName() + "\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><button value=\"delete\" action=\"bypass -h admin_event_del " + file.getName() + "\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><br><br>";
}
return result;
}
public void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>");
replyMSG.append("<br><center><button value=\"Create NEW event \" action=\"bypass -h admin_event_new\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("<center><br>Stored Events<br></center>");
replyMSG.append(showStoredEvents());
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showNewEventPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>");
replyMSG.append("<br><center>Event's Title <br><font color=\"LEVEL\">");
if (tempName.equals(""))
{
replyMSG.append("Use //event_name text to insert a new title");
}
else
{
replyMSG.append(tempName);
}
replyMSG.append("</font></center><br><br>Event's description<br>");
if (tempBuffer.equals(""))
{
replyMSG.append("Use //add text o //delete_buffer to modify this text field");
}
else
{
replyMSG.append(tempBuffer);
}
if (!(tempName.equals("") && tempBuffer.equals("")))
{
replyMSG.append("<br><button value=\"Crear\" action=\"bypass -h admin_event_store\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
}
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showEventParameters(L2PcInstance activeChar, int teamnumbers)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>");
replyMSG.append("<center><font color=\"LEVEL\">" + L2Event.eventName + "</font></center><br>");
replyMSG.append("<br><center><button value=\"Change number of teams to\" action=\"bypass -h admin_event_change_teams_number $event_teams_number\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"> <edit var=\"event_teams_number\" width=100 height=20><br><br>");
replyMSG.append("<font color=\"LEVEL\">Team's Names</font><br>");
for (int i = 0; i < teamnumbers; i++)
{
replyMSG.append((i + 1) + ".- <edit var=\"event_teams_name" + (i + 1) + "\" width=100 height=20><br>");
}
replyMSG.append("<br><br>Announcer NPC id<edit var=\"event_npcid\" width=100 height=20><br><br><button value=\"Announce Event!!\" action=\"bypass -h admin_event_announce $event_npcid " + teamnumbers + " ");
for (int i = 0; i < teamnumbers; i++)
{
replyMSG.append("$event_teams_name" + (i + 1) + " - ");
}
replyMSG.append("\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void muestraNpcConInfoAPlayers(L2PcInstance activeChar, int id)
{
L2Event.npcs.clear();
final LinkedList<L2PcInstance> temp = new LinkedList<>();
temp.clear();
for (final L2PcInstance player : L2World.getInstance().getAllPlayers())
{
if (!temp.contains(player))
{
L2Event.spawn(player, id);
temp.add(player);
}
for (final L2PcInstance playertemp : player.getKnownList().getKnownPlayers().values())
{
if ((Math.abs(playertemp.getX() - player.getX()) < 500) && (Math.abs(playertemp.getY() - player.getY()) < 500) && (Math.abs(playertemp.getZ() - player.getZ()) < 500))
{
temp.add(playertemp);
}
}
}
L2Event.announceAllPlayers(activeChar.getName() + " wants to make an event !!! (you'll find a npc with the details around)");
}
private void showEventControl(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br><font color=\"LEVEL\">" + L2Event.eventName + "</font><br><br><table width=200>");
replyMSG.append("<tr><td>Apply this command to teams number </td><td><edit var=\"team_number\" width=100 height=15></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
if (!npcsDeleted)
{
replyMSG.append("<tr><td><button value=\"Start\" action=\"bypass -h admin_event_control_begin\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Destroys all event npcs so no more people can't participate now on</font></td></tr>");
}
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"Teleport\" action=\"bypass -h admin_event_control_teleport $team_number\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Teleports the specified team to your position</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"Sit\" action=\"bypass -h admin_event_control_sit $team_number\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Sits/Stands up the team</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"Kill\" action=\"bypass -h admin_event_control_kill $team_number\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Finish with the life of all the players in the selected team</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"Resurrect\" action=\"bypass -h admin_event_control_res $team_number\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Resurrect Team's members</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"Polymorph\" action=\"bypass -h admin_event_control_poly $team_number $poly_id\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><edit var=\"poly_id\" width=100 height=15><font color=\"LEVEL\">Polymorphs the team into the NPC with the id specified</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"UnPolymorph\" action=\"bypass -h admin_event_control_unpoly $team_number\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Unpolymorph the team</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"Give Item\" action=\"bypass -h admin_event_control_prize $team_number $n $id\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"> number <edit var=\"n\" width=100 height=15> item id <edit var=\"id\" width=100 height=15></td><td><font color=\"LEVEL\">Give the specified item id to every single member of the team, you can put 5*level, 5*kills or 5 in the number field for example</font></td></tr>");
replyMSG.append("<tr><td>&nbsp;</td></tr>");
replyMSG.append("<tr><td><button value=\"End\" action=\"bypass -h admin_event_control_finish\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><font color=\"LEVEL\">Will finish the event teleporting back all the players</font></td></tr>");
replyMSG.append("</table></body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private String getMaxLeveledPlayer()
{
L2PcInstance pc = null;
int max = 0;
String name = "";
for (final String tempName2 : L2Event.participatingPlayers)
{
try
{
pc = L2World.getInstance().getPlayer(tempName2);
if (max < pc.getLevel())
{
max = pc.getLevel();
name = tempName2;
}
}
catch (final Exception e)
{
L2Event.participatingPlayers.remove(tempName2);
}
}
L2Event.participatingPlayers.remove(name);
return name;
}
private void destroyEventNpcs()
{
L2NpcInstance npc;
while (L2Event.npcs.size() > 0)
{
try
{
npc = (L2NpcInstance) L2World.getInstance().findObject(Integer.parseInt(L2Event.npcs.getFirst()));
final L2Spawn spawn = npc.getSpawn();
if (spawn != null)
{
spawn.stopRespawn();
SpawnTable.getInstance().deleteSpawn(spawn, true);
}
npc.deleteMe();
L2Event.npcs.removeFirst();
}
catch (final Exception e)
{
L2Event.npcs.removeFirst();
}
}
}
private void teleportTeam(L2PcInstance activeChar, int team)
{
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance pc = L2World.getInstance().getPlayer(it.next().toString());
pc.setTitle(L2Event.names.get(team));
pc.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), true);
}
catch (final Exception e)
{
}
}
}
private void sitTeam(int team)
{
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance pc = L2World.getInstance().getPlayer(it.next().toString());
pc.eventSitForced = !pc.eventSitForced;
if (pc.eventSitForced)
{
if (pc.isCastingNow())
{
pc.abortCast();
}
pc.sitDown();
}
else
{
pc.standUp();
}
}
catch (final Exception e)
{
}
}
}
private void killTeam(L2PcInstance activeChar, int team)
{
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar);
}
catch (final Exception e)
{
}
}
}
private void resTeam(int team)
{
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
final L2PcInstance character = L2World.getInstance().getPlayer(it.next().toString());
if ((character == null) || !character.isDead())
{
continue;
}
character.restoreExp(100.0);
character.doRevive();
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
character.setCurrentCp(character.getMaxCp());
}
}
private void polyTeam(int team, String id)
{
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
target.getPoly().setPolyInfo("npc", id);
target.teleToLocation(target.getX(), target.getY(), target.getZ(), true);
final CharInfo info1 = new CharInfo(target);
target.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(target);
target.sendPacket(info2);
}
catch (final Exception e)
{
}
}
}
private void unpolyTeam(int team)
{
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
target.getPoly().setPolyInfo(null, "1");
target.decayMe();
target.spawnMe(target.getX(), target.getY(), target.getZ());
final CharInfo info1 = new CharInfo(target);
target.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(target);
target.sendPacket(info2);
}
catch (final Exception e)
{
}
}
}
private void createItem(L2PcInstance activeChar, L2PcInstance player, int id, int num)
{
player.getInventory().addItem("Event", id, num, player, activeChar);
final ItemList il = new ItemList(player, true);
player.sendPacket(il);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("CONGRATULATIONS, you should have a present in your inventory");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
player.sendPacket(adminReply);
}
private void regardTeam(L2PcInstance activeChar, int team, int n, int id, String type)
{
final LinkedList<?> linked = L2Event.players.get(team);
int temp = n;
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
if (type.equalsIgnoreCase("level"))
{
temp = n * target.getLevel();
}
else if (type.equalsIgnoreCase("kills"))
{
temp = n * target.kills.size();
}
else
{
temp = n;
}
createItem(activeChar, target, id, temp);
}
catch (final Exception e)
{
}
}
}
private void telePlayersBack(int team)
{
resTeam(team);
unpolyTeam(team);
final LinkedList<?> linked = L2Event.players.get(team);
final Iterator<?> it = linked.iterator();
while (it.hasNext())
{
try
{
final L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
target.setTitle(target.eventTitle);
target.setKarma(target.eventkarma);
target.setPvpKills(target.eventpvpkills);
target.setPkKills(target.eventpkkills);
target.teleToLocation(target.eventX, target.eventY, target.eventZ, true);
target.kills.clear();
target.eventSitForced = false;
target.atEvent = false;
}
catch (final Exception e)
{
}
}
}
}

View File

@@ -0,0 +1,321 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - add_exp_sp_to_character = show menu - add_exp_sp exp sp = adds exp & sp to target
* @version $Revision: 1.2.4.6 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminExpSp implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminExpSp.class.getName());
private static String[] _adminCommands =
{
"admin_add_exp_sp_to_character",
"admin_add_exp_sp",
"admin_remove_exp_sp"
};
private static final int REQUIRED_LEVEL = Config.GM_CHAR_EDIT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_add_exp_sp_to_character"))
{
addExpSp(activeChar);
GMAudit.auditGMAction(activeChar.getName(), command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"), "");
}
else if (command.startsWith("admin_add_exp_sp"))
{
try
{
final String val = command.substring(16);
adminAddExpSp(activeChar, val);
GMAudit.auditGMAction(activeChar.getName(), command, val, "");
}
catch (final StringIndexOutOfBoundsException e)
{ // Case of empty character name
final SystemMessage sm = new SystemMessage(614);
sm.addString("Error while adding Exp-Sp.");
activeChar.sendPacket(sm);
// listCharacters(client, 0);
}
}
else if (command.startsWith("admin_remove_exp_sp"))
{
try
{
final String val = command.substring(19);
adminRemoveExpSP(activeChar, val);
GMAudit.auditGMAction(activeChar.getName(), command, val, "");
}
catch (final StringIndexOutOfBoundsException e)
{ // Case of empty character name
final SystemMessage sm = new SystemMessage(614);
sm.addString("Error while removing Exp-Sp.");
activeChar.sendPacket(sm);
// listCharacters(client, 0);
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void addExpSp(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Character Selection Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<center>Editing <font color=\"LEVEL\">" + player.getName() + "</font></center>");
replyMSG.append("<table width=270>");
replyMSG.append("<tr><td>Level: " + player.getLevel() + "</td></tr>");
replyMSG.append("<tr><td>Class: " + player.getTemplate().className + "</td></tr>");
replyMSG.append("<tr><td>Exp: " + player.getExp() + "</td></tr>");
replyMSG.append("<tr><td>SP: " + player.getSp() + "</td></tr></table>");
replyMSG.append("<table width=270><tr><td>Note: Fill BOTH values before saving the modifications</td></tr>");
replyMSG.append("<tr><td>and use 0 if no changes are needed.</td></tr></table><br>");
replyMSG.append("<center><table><tr>");
replyMSG.append("<td>Exp: <edit var=\"exp_to_add\" width=50></td>");
replyMSG.append("<td>SP: <edit var=\"sp_to_add\" width=50></td>");
replyMSG.append("<td>&nbsp;<center><button value=\"Add\" action=\"bypass -h admin_add_exp_sp $exp_to_add $sp_to_add\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></td>");
replyMSG.append("<td>&nbsp;<center><button value=\"Remove\" action=\"bypass -h admin_remove_exp_sp $exp_to_add $sp_to_add\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></td>");
replyMSG.append("</tr></table></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void removeExp(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Character Selection Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<center>Editing <font color=\"LEVEL\">" + player.getName() + "</font></center>");
replyMSG.append("<table width=270>");
replyMSG.append("<tr><td>Level: " + player.getLevel() + "</td></tr>");
replyMSG.append("<tr><td>Class: " + player.getTemplate().className + "</td></tr>");
replyMSG.append("<tr><td>Exp: " + player.getExp() + "</td></tr>");
replyMSG.append("<tr><td>SP: " + player.getSp() + "</td></tr></table>");
replyMSG.append("<table width=270><tr><td>Note: Fill BOTH values before saving the modifications</td></tr>");
replyMSG.append("<tr><td>and use 0 if no changes are needed.</td></tr></table><br>");
replyMSG.append("<center><table><tr>");
replyMSG.append("<td>remove Exp: <edit var=\"exp_to_remove\" width=50></td>");
replyMSG.append("<td>remove SP: <edit var=\"sp_to_remove\" width=50></td>");
replyMSG.append("<td>&nbsp;<button value=\"Save Changes\" action=\"bypass -h admin_remove_exp_sp $exp_to_remove $sp_to_remove\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void adminAddExpSp(L2PcInstance activeChar, String ExpSp)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final StringTokenizer st = new StringTokenizer(ExpSp);
if (st.countTokens() != 2)
{
addExpSp(activeChar);
}
else
{
final String exp = st.nextToken();
final String sp = st.nextToken();
long expval = 0;
int spval = 0;
try
{
expval = Long.parseLong(exp);
spval = Integer.parseInt(sp);
}
catch (final NumberFormatException e)
{
// Wrong number (maybe it's too big?)
final SystemMessage smA = new SystemMessage(614);
smA.addString("Wrong Number Format");
activeChar.sendPacket(smA);
}
if ((expval != 0) || (spval != 0))
{
// Common character information
final SystemMessage sm = new SystemMessage(614);
sm.addString("Admin is adding you " + expval + " xp and " + spval + " sp.");
player.sendPacket(sm);
player.addExpAndSp(expval, spval);
// Admin information
final SystemMessage smA = new SystemMessage(614);
smA.addString("Added " + expval + " xp and " + spval + " sp to " + player.getName() + ".");
activeChar.sendPacket(smA);
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") added " + expval + " xp and " + spval + " sp to " + player.getObjectId() + ".");
}
}
}
}
private void adminRemoveExpSP(L2PcInstance activeChar, String ExpSp)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final StringTokenizer st = new StringTokenizer(ExpSp);
if (st.countTokens() != 2)
{
removeExp(activeChar);
}
else
{
final String exp = st.nextToken();
final String sp = st.nextToken();
long expval = 0;
int spval = 0;
try
{
expval = Long.parseLong(exp);
spval = Integer.parseInt(sp);
}
catch (final NumberFormatException e)
{
// Wrong number (maybe it's too big?)
final SystemMessage smA = new SystemMessage(614);
smA.addString("Wrong Number Format");
activeChar.sendPacket(smA);
}
if ((expval != 0) || (spval != 0))
{
// Common character information
final SystemMessage sm = new SystemMessage(614);
sm.addString("Admin is removing you " + expval + " xp and " + spval + " sp.");
player.sendPacket(sm);
player.removeExpAndSp(expval, spval);
// Admin information
final SystemMessage smA = new SystemMessage(614);
smA.addString("Removed " + expval + " xp and " + spval + " sp from " + player.getName() + ".");
activeChar.sendPacket(smA);
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") added " + expval + " xp and " + spval + " sp to " + player.getObjectId() + ".");
}
}
}
}
}

View File

@@ -0,0 +1,399 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.NpcTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.skills.Formulas;
import com.l2jmobius.gameserver.templates.L2NpcTemplate;
import com.l2jmobius.util.Rnd;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - gm = turns gm mode on/off
* @version $Revision: 1.1.2.1 $ $Date: 2005/03/15 21:32:48 $
*/
public class AdminFightCalculator implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_fight_calculator",
"admin_fight_calculator_show",
"admin_fcs"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
// TODO: remove from gm list etc etc
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
try
{
// don't check for gm status ;)
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!checkLevel(activeChar.getAccessLevel()))
{
return false;
}
}
if (command.startsWith("admin_fight_calculator_show"))
{
handleShow(command.substring("admin_fight_calculator_show".length()), activeChar);
}
else if (command.startsWith("admin_fcs"))
{
handleShow(command.substring("admin_fcs".length()), activeChar);
}
else if (command.startsWith("admin_fight_calculator"))
{
handleStart(command.substring("admin_fight_calculator".length()), activeChar);
}
}
catch (final StringIndexOutOfBoundsException e)
{
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleStart(String params, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(params);
int lvl1 = 0;
int lvl2 = 0;
int mid1 = 0;
int mid2 = 0;
while (st.hasMoreTokens())
{
final String s = st.nextToken();
if (s.equals("lvl1"))
{
lvl1 = Integer.parseInt(st.nextToken());
continue;
}
if (s.equals("lvl2"))
{
lvl2 = Integer.parseInt(st.nextToken());
continue;
}
if (s.equals("mid1"))
{
mid1 = Integer.parseInt(st.nextToken());
continue;
}
if (s.equals("mid2"))
{
mid2 = Integer.parseInt(st.nextToken());
continue;
}
}
L2NpcTemplate npc1 = null;
if (mid1 != 0)
{
npc1 = NpcTable.getInstance().getTemplate(mid1);
}
L2NpcTemplate npc2 = null;
if (mid2 != 0)
{
npc2 = NpcTable.getInstance().getTemplate(mid2);
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder();
if ((npc1 != null) && (npc2 != null))
{
replyMSG.append("<html><title>Selected mobs to fight</title>");
replyMSG.append("<body>");
replyMSG.append("<table>");
replyMSG.append("<tr><td>First</td><td>Second</td></tr>");
replyMSG.append("<tr><td>level " + lvl1 + "</td><td>level " + lvl2 + "</td></tr>");
replyMSG.append("<tr><td>id " + npc1.npcId + "</td><td>id " + npc2.npcId + "</td></tr>");
replyMSG.append("<tr><td>" + npc1.name + "</td><td>" + npc2.name + "</td></tr>");
replyMSG.append("</table>");
replyMSG.append("<center><br><br><br>");
replyMSG.append("<button value=\"OK\" action=\"bypass -h admin_fight_calculator_show " + npc1.npcId + " " + npc2.npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</center>");
replyMSG.append("</body></html>");
}
else if ((lvl1 != 0) && (npc1 == null))
{
replyMSG.append("<html><title>Select first mob to fight</title>");
replyMSG.append("<body><table>");
final L2NpcTemplate[] npcs = NpcTable.getInstance().getAllOfLevel(lvl1);
for (final L2NpcTemplate n : npcs)
{
replyMSG.append("<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 " + lvl1 + " lvl2 " + lvl2 + " mid1 " + n.npcId + " mid2 " + mid2 + "\">" + n.name + "</a></td></tr>");
}
replyMSG.append("</table></body></html>");
}
else if ((lvl2 != 0) && (npc2 == null))
{
replyMSG.append("<html><title>Select second mob to fight</title>");
replyMSG.append("<body><table>");
final L2NpcTemplate[] npcs = NpcTable.getInstance().getAllOfLevel(lvl2);
for (final L2NpcTemplate n : npcs)
{
replyMSG.append("<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 " + lvl1 + " lvl2 " + lvl2 + " mid1 " + mid1 + " mid2 " + n.npcId + "\">" + n.name + "</a></td></tr>");
}
replyMSG.append("</table></body></html>");
}
else
{
replyMSG.append("<html><title>Select mobs to fight</title>");
replyMSG.append("<body>");
replyMSG.append("<table>");
replyMSG.append("<tr><td>First</td><td>Second</td></tr>");
replyMSG.append("<tr><td><edit var=\"lvl1\" width=80></td><td><edit var=\"lvl2\" width=80></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<center><br><br><br>");
replyMSG.append("<button value=\"OK\" action=\"bypass -h admin_fight_calculator lvl1 $lvl1 lvl2 $lvl2\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</center>");
replyMSG.append("</body></html>");
}
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void handleShow(String params, L2PcInstance activeChar)
{
final Formulas f = Formulas.getInstance();
params = params.trim();
L2Character npc1 = null;
L2Character npc2 = null;
if (params.length() == 0)
{
npc1 = activeChar;
npc2 = (L2Character) activeChar.getTarget();
if (npc2 == null)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
return;
}
}
else
{
int mid1 = 0;
int mid2 = 0;
final StringTokenizer st = new StringTokenizer(params);
mid1 = Integer.parseInt(st.nextToken());
mid2 = Integer.parseInt(st.nextToken());
npc1 = new L2MonsterInstance(IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(mid1));
npc2 = new L2MonsterInstance(IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(mid2));
}
int miss1 = 0;
int miss2 = 0;
int shld1 = 0;
int shld2 = 0;
int crit1 = 0;
int crit2 = 0;
double patk1 = 0;
double patk2 = 0;
double pdef1 = 0;
double pdef2 = 0;
double dmg1 = 0;
double dmg2 = 0;
// ATTACK speed in milliseconds
int sAtk1 = npc1.calculateTimeBetweenAttacks(npc2, null);
int sAtk2 = npc2.calculateTimeBetweenAttacks(npc1, null);
// number of ATTACK per 100 seconds
sAtk1 = 100000 / sAtk1;
sAtk2 = 100000 / sAtk2;
for (int i = 0; i < 10000; i++)
{
final boolean _miss1 = f.calcHitMiss(npc1, npc2);
if (_miss1)
{
miss1++;
}
final boolean _shld1 = f.calcShldUse(npc1, npc2);
if (_shld1)
{
shld1++;
}
final boolean _crit1 = f.calcCrit(npc1.getCriticalHit(npc2, null));
if (_crit1)
{
crit1++;
}
double _patk1 = npc1.getPAtk(npc2);
_patk1 += Rnd.nextDouble() * npc1.getRandomDamage(npc2);
patk1 += _patk1;
final double _pdef1 = npc1.getPDef(npc2);
pdef1 += _pdef1;
if (!_miss1)
{
npc1.setAttackingBodypart();
final double _dmg1 = f.calcPhysDam(npc1, npc2, null, _shld1, _crit1, false, false);
dmg1 += _dmg1;
npc1.abortAttack();
}
}
for (int i = 0; i < 10000; i++)
{
final boolean _miss2 = f.calcHitMiss(npc2, npc1);
if (_miss2)
{
miss2++;
}
final boolean _shld2 = f.calcShldUse(npc2, npc1);
if (_shld2)
{
shld2++;
}
final boolean _crit2 = f.calcCrit(npc2.getCriticalHit(npc1, null));
if (_crit2)
{
crit2++;
}
double _patk2 = npc2.getPAtk(npc1);
_patk2 += Rnd.nextDouble() * npc2.getRandomDamage(npc1);
patk2 += _patk2;
final double _pdef2 = npc2.getPDef(npc1);
pdef2 += _pdef2;
if (!_miss2)
{
npc2.setAttackingBodypart();
final double _dmg2 = f.calcPhysDam(npc2, npc1, null, _shld2, _crit2, false, false);
dmg2 += _dmg2;
npc2.abortAttack();
}
}
miss1 /= 100;
miss2 /= 100;
shld1 /= 100;
shld2 /= 100;
crit1 /= 100;
crit2 /= 100;
patk1 /= 10000;
patk2 /= 10000;
pdef1 /= 10000;
pdef2 /= 10000;
dmg1 /= 10000;
dmg2 /= 10000;
// total damage per 100 seconds
final int tdmg1 = (int) (sAtk1 * dmg1);
final int tdmg2 = (int) (sAtk2 * dmg2);
// HP restored per 100 seconds
final double maxHp1 = npc1.getMaxHp();
final int hp1 = (int) ((f.calcHpRegen(npc1) * 100000) / f.getRegeneratePeriod(npc1));
final double maxHp2 = npc2.getMaxHp();
final int hp2 = (int) ((f.calcHpRegen(npc2) * 100000) / f.getRegeneratePeriod(npc2));
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder();
replyMSG.append("<html><title>Selected mobs to fight</title>");
replyMSG.append("<body>");
replyMSG.append("<table>");
if (params.length() == 0)
{
replyMSG.append("<tr><td width=140>Parameter</td><td width=70>me</td><td width=70>target</td></tr>");
}
else
{
replyMSG.append("<tr><td width=140>Parameter</td><td width=70>" + ((L2NpcTemplate) npc1.getTemplate()).name + "</td><td width=70>" + ((L2NpcTemplate) npc2.getTemplate()).name + "</td></tr>");
}
replyMSG.append("<tr><td>miss</td><td>" + miss1 + "%</td><td>" + miss2 + "%</td></tr>");
replyMSG.append("<tr><td>shld</td><td>" + shld2 + "%</td><td>" + shld1 + "%</td></tr>");
replyMSG.append("<tr><td>crit</td><td>" + crit1 + "%</td><td>" + crit2 + "%</td></tr>");
replyMSG.append("<tr><td>pAtk / pDef</td><td>" + ((int) patk1) + " / " + ((int) pdef1) + "</td><td>" + ((int) patk2) + " / " + ((int) pdef2) + "</td></tr>");
replyMSG.append("<tr><td>made hits</td><td>" + sAtk1 + "</td><td>" + sAtk2 + "</td></tr>");
replyMSG.append("<tr><td>dmg per hit</td><td>" + ((int) dmg1) + "</td><td>" + ((int) dmg2) + "</td></tr>");
replyMSG.append("<tr><td>got dmg</td><td>" + tdmg2 + "</td><td>" + tdmg1 + "</td></tr>");
replyMSG.append("<tr><td>got regen</td><td>" + hp1 + "</td><td>" + hp2 + "</td></tr>");
replyMSG.append("<tr><td>had HP</td><td>" + (int) maxHp1 + "</td><td>" + (int) maxHp2 + "</td></tr>");
replyMSG.append("<tr><td>die</td>");
if ((tdmg2 - hp1) > 1)
{
replyMSG.append("<td>" + (int) ((100 * maxHp1) / (tdmg2 - hp1)) + " sec</td>");
}
else
{
replyMSG.append("<td>never</td>");
}
if ((tdmg1 - hp2) > 1)
{
replyMSG.append("<td>" + (int) ((100 * maxHp2) / (tdmg1 - hp2)) + " sec</td>");
}
else
{
replyMSG.append("<td>never</td>");
}
replyMSG.append("</tr>");
replyMSG.append("</table>");
replyMSG.append("<center><br>");
if (params.length() == 0)
{
replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
}
else
{
replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show " + ((L2NpcTemplate) npc1.getTemplate()).npcId + " " + ((L2NpcTemplate) npc2.getTemplate()).npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
}
replyMSG.append("</center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
if (params.length() != 0)
{
((L2MonsterInstance) npc1).deleteMe();
((L2MonsterInstance) npc2).deleteMe();
}
}
}

View File

@@ -0,0 +1,134 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.geoeditorcon.GeoEditorListener;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Luno, Dezmond
*/
public class AdminGeoEditor implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_ge_status",
"admin_ge_mode",
"admin_ge_join",
"admin_ge_leave"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target";
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (!Config.ACCEPT_GEOEDITOR_CONN)
{
activeChar.sendMessage("Server does not accept geoeditor connections now.");
return true;
}
if (command.startsWith("admin_ge_status"))
{
activeChar.sendMessage(GeoEditorListener.getInstance().getStatus());
}
else if (command.startsWith("admin_ge_mode"))
{
if (GeoEditorListener.getInstance().getThread() == null)
{
activeChar.sendMessage("Geoeditor is not connected.");
return true;
}
try
{
final String val = command.substring("admin_ge_mode".length());
final StringTokenizer st = new StringTokenizer(val);
if (st.countTokens() < 1)
{
activeChar.sendMessage("Usage: //ge_mode X");
activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
activeChar.sendMessage("Mode 2: Send coordinates each second.");
return true;
}
final int m = Integer.parseInt(st.nextToken());
GeoEditorListener.getInstance().getThread().setMode(m);
activeChar.sendMessage("Geoeditor connection mode set to " + m + ".");
}
catch (final Exception e)
{
activeChar.sendMessage("Usage: //ge_mode X");
activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
activeChar.sendMessage("Mode 2: Send coordinates each second.");
e.printStackTrace();
}
}
else if (command.equals("admin_ge_join"))
{
if (GeoEditorListener.getInstance().getThread() == null)
{
activeChar.sendMessage("Geoeditor is not connected.");
return true;
}
GeoEditorListener.getInstance().getThread().addGM(activeChar);
activeChar.sendMessage("You have been added to geoeditor's list.");
}
else if (command.equals("admin_ge_leave"))
{
if (GeoEditorListener.getInstance().getThread() == null)
{
activeChar.sendMessage("Geoeditor is not connected.");
return true;
}
GeoEditorListener.getInstance().getThread().removeGM(activeChar);
activeChar.sendMessage("You have been removed from geoeditor's list.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,141 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author -Nemesiss-
*/
public class AdminGeodata implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_geo_pos",
"admin_geo_spawn_pos",
"admin_geo_can_move",
"admin_geo_can_see"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_geo_pos"))
{
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoData.getInstance().getGeoX(worldX);
final int geoY = GeoData.getInstance().getGeoY(worldY);
if (GeoData.getInstance().hasGeoPos(geoX, geoY))
{
activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getNearestZ(geoX, geoY, worldZ));
}
else
{
activeChar.sendMessage("There is no geodata at this position.");
}
}
else if (command.equals("admin_geo_spawn_pos"))
{
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoData.getInstance().getGeoX(worldX);
final int geoY = GeoData.getInstance().getGeoY(worldY);
if (GeoData.getInstance().hasGeoPos(geoX, geoY))
{
activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getSpawnHeight(worldX, worldY, worldZ, worldZ));
}
else
{
activeChar.sendMessage("There is no geodata at this position.");
}
}
else if (command.equals("admin_geo_can_move"))
{
final L2Object target = activeChar.getTarget();
if (target != null)
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
activeChar.sendMessage("Can move beeline.");
}
else
{
activeChar.sendMessage("Can not move beeline!");
}
}
else
{
activeChar.sendMessage("Incorrect Target.");
}
}
else if (command.equals("admin_geo_can_see"))
{
final L2Object target = activeChar.getTarget();
if (target != null)
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
activeChar.sendMessage("Can see target.");
}
else
{
activeChar.sendMessage("Cannot see Target.");
}
}
else
{
activeChar.sendMessage("Incorrect Target.");
}
}
else
{
return false;
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,98 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.GmListTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - gm = turns gm mode on/off
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminGm implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminGm.class.getName());
private static String[] _adminCommands =
{
"admin_gm"
};
private static final int REQUIRED_LEVEL = Config.GM_ACCESSLEVEL;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
// don't check for gm status ;)
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!checkLevel(activeChar.getAccessLevel()))
{
return false;
}
}
if (command.equals("admin_gm"))
{
handleGm(activeChar);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleGm(L2PcInstance activeChar)
{
if (activeChar.isGM())
{
GmListTable.getInstance().deleteGm(activeChar);
activeChar.setIsGM(false);
activeChar.sendMessage("You no longer have GM status.");
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") turned his GM status off");
}
}
else
{
GmListTable.getInstance().addGm(activeChar, false);
activeChar.setIsGM(true);
activeChar.sendMessage("You now have GM status.");
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") turned his GM status on");
}
}
}
}

View File

@@ -0,0 +1,108 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.GmListTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
/**
* This class handles following admin commands: - gmchat text = sends text to all online GM's
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminGmChat implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_gmchat",
"admin_snoop"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_gmchat"))
{
handleGmChat(command, activeChar);
}
else if (command.startsWith("admin_snoop"))
{
snoop(command, activeChar);
}
return true;
}
/**
* @param command
* @param activeChar
*/
private void snoop(String command, L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
if (target == null)
{
activeChar.sendMessage("You must select a target.");
return;
}
if (!(target instanceof L2PcInstance))
{
activeChar.sendMessage("Target must be a player.");
return;
}
final L2PcInstance player = (L2PcInstance) target;
player.addSnooper(activeChar);
activeChar.addSnooped(player);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleGmChat(String command, L2PcInstance activeChar)
{
try
{
final String text = command.substring(13);
final CreatureSay cs = new CreatureSay(0, 9, activeChar.getName(), text);
GmListTable.broadcastToGMs(cs);
}
catch (final StringIndexOutOfBoundsException e)
{
// empty message.. ignore
}
}
}

View File

@@ -0,0 +1,157 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - res = resurrects target L2Character
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminHeal implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminRes.class.getName());
private static String[] _adminCommands =
{
"admin_heal"
};
private static final int REQUIRED_LEVEL = Config.GM_HEAL;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_heal"))
{
handleRes(activeChar);
}
else if (command.startsWith("admin_heal"))
{
try
{
final String healTarget = command.substring(11);
handleRes(activeChar, healTarget);
}
catch (final StringIndexOutOfBoundsException e)
{
if (Config.DEVELOPER)
{
System.out.println("Heal error: " + e);
}
final SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
sm.addString("Incorrect target/radius specified.");
activeChar.sendPacket(sm);
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleRes(L2PcInstance activeChar)
{
handleRes(activeChar, null);
}
private void handleRes(L2PcInstance activeChar, String player)
{
L2Object obj = activeChar.getTarget();
if (player != null)
{
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
if (plyr != null)
{
obj = plyr;
}
else
{
try
{
final int radius = Integer.parseInt(player);
for (final L2Object object : activeChar.getKnownList().getKnownObjects().values())
{
if (object instanceof L2Character)
{
final L2Character character = (L2Character) object;
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
if (object instanceof L2PcInstance)
{
character.setCurrentCp(character.getMaxCp());
}
}
}
activeChar.sendMessage("Healed within " + radius + " unit radius.");
return;
}
catch (final NumberFormatException nbe)
{
}
}
}
if (obj == null)
{
obj = activeChar;
}
if (obj instanceof L2Character)
{
final L2Character target = (L2Character) obj;
target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp());
if (target instanceof L2PcInstance)
{
target.setCurrentCp(target.getMaxCp());
}
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") healed character " + target.getName());
}
}
else
{
final SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
}
}
}

View File

@@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* This class handles following admin commands: - help path = shows /data/html/admin/path file to char, should not be used by GM's directly
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:06:02 $
*/
public class AdminHelpPage implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_help"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!checkLevel(activeChar.getAccessLevel()))
{
return false;
}
}
if (command.startsWith("admin_help"))
{
try
{
final String val = command.substring(11);
showHelpPage(activeChar, val);
}
catch (final StringIndexOutOfBoundsException e)
{
// case of empty filename
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
// FIXME: implement method to send html to player in L2PcInstance directly
// PUBLIC & STATIC so other classes from package can include it directly
public static void showHelpPage(L2PcInstance targetChar, String filename)
{
final String content = HtmCache.getInstance().getHtmForce("data/html/admin/" + filename);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setHtml(content);
targetChar.sendPacket(adminReply);
}
}

View File

@@ -0,0 +1,108 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - invul = turns invulnerability on/off
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:02 $
*/
public class AdminInvul implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminInvul.class.getName());
private static String[] _adminCommands =
{
"admin_invul",
"admin_setinvul"
};
private static final int REQUIRED_LEVEL = Config.GM_GODMODE;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
GMAudit.auditGMAction(activeChar.getName(), command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"), "");
if (command.equals("admin_invul"))
{
handleInvul(activeChar);
}
else if (command.equals("admin_setinvul"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
{
handleInvul((L2PcInstance) target);
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleInvul(L2PcInstance activeChar)
{
if (activeChar.isInvul())
{
activeChar.setIsInvul(false);
final String text = activeChar.getName() + " is now mortal.";
final SystemMessage sm = new SystemMessage(614);
sm.addString(text);
activeChar.sendPacket(sm);
if (Config.DEBUG)
{
_log.fine("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
}
}
else
{
activeChar.setIsInvul(true);
final String text = activeChar.getName() + " is now invulnerable.";
final SystemMessage sm = new SystemMessage(614);
sm.addString(text);
activeChar.sendPacket(sm);
if (Config.DEBUG)
{
_log.fine("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
}
}
}
}

View File

@@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class AdminKick implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_kick",
"admin_kick_non_gm"
};
private static final int REQUIRED_LEVEL = Config.GM_KICK;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (command.startsWith("admin_kick"))
{
final StringTokenizer st = new StringTokenizer(command);
if (st.countTokens() > 1)
{
st.nextToken();
final String player = st.nextToken();
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
if (plyr != null)
{
plyr.logout();
activeChar.sendMessage("You kicked " + plyr.getName() + " from the game.");
}
}
}
if (command.startsWith("admin_kick_non_gm"))
{
int counter = 0;
for (final L2PcInstance player : L2World.getInstance().getAllPlayers())
{
if (!player.isGM())
{
counter++;
player.logout();
}
}
activeChar.sendMessage("Kicked " + counter + " players.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,174 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - kill = kills target L2Character - kill_monster = kills target non-player - kill <radius> = If radius is specified, then ALL players only in that radius will be killed. - kill_monster <radius> = If radius is specified, then ALL non-players only in
* that radius will be killed.
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminKill implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminKill.class.getName());
private static String[] _adminCommands =
{
"admin_kill",
"admin_kill_monster"
};
private static final int REQUIRED_LEVEL = Config.GM_NPC_EDIT;
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target";
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (command.startsWith("admin_kill"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken(); // skip command
if (st.hasMoreTokens())
{
final String firstParam = st.nextToken();
final L2PcInstance plyr = L2World.getInstance().getPlayer(firstParam);
if (plyr != null)
{
if (st.hasMoreTokens())
{
try
{
final int radius = Integer.parseInt(st.nextToken());
for (final L2Character knownChar : plyr.getKnownList().getKnownCharactersInRadius(radius))
{
if ((knownChar == null) || (knownChar instanceof L2ControllableMobInstance) || knownChar.equals(activeChar))
{
continue;
}
kill(activeChar, knownChar);
}
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
return true;
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Invalid radius.");
return false;
}
}
kill(activeChar, plyr);
}
else
{
try
{
final int radius = Integer.parseInt(firstParam);
for (final L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
{
if ((knownChar == null) || (knownChar instanceof L2ControllableMobInstance) || knownChar.equals(activeChar))
{
continue;
}
kill(activeChar, knownChar);
}
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
return true;
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Enter a valid player name or radius.");
return false;
}
}
}
else
{
final L2Object obj = activeChar.getTarget();
if ((obj == null) || (obj instanceof L2ControllableMobInstance) || !(obj instanceof L2Character))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
}
else
{
kill(activeChar, (L2Character) obj);
}
}
}
return true;
}
private void kill(L2PcInstance activeChar, L2Character target)
{
if (target instanceof L2PcInstance)
{
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar);
}
else if (Config.CHAMPION_ENABLE && target.isChampion())
{
target.reduceCurrentHp((target.getMaxHp() * Config.CHAMPION_HP) + 1, activeChar);
}
else
{
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar);
}
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ")" + " killed character " + target.getObjectId());
}
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,137 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.model.base.Experience;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class AdminLevel implements IAdminCommandHandler
{
private static final int REQUIRED_LEVEL = Config.GM_CHAR_EDIT;
public static final String[] ADMIN_COMMANDS =
{
"admin_add_level",
"admin_set_level"
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (activeChar == null)
{
return false;
}
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (activeChar.getAccessLevel() < REQUIRED_LEVEL)
{
return false;
}
}
final L2Object targetChar = activeChar.getTarget();
final String target = (targetChar != null ? targetChar.getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
final StringTokenizer st = new StringTokenizer(command, " ");
final String actualCommand = st.nextToken(); // Get actual command
String val = "";
if (st.countTokens() >= 1)
{
val = st.nextToken();
}
if (actualCommand.equalsIgnoreCase("admin_add_level"))
{
try
{
if (targetChar instanceof L2PlayableInstance)
{
((L2PlayableInstance) targetChar).getStat().addLevel(Byte.parseByte(val));
}
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Wrong Number Format");
}
}
else if (actualCommand.equalsIgnoreCase("admin_set_level"))
{
try
{
if ((targetChar == null) || !(targetChar instanceof L2PcInstance))
{
activeChar.sendPacket(new SystemMessage(144)); // incorrect target!
return false;
}
final L2PcInstance targetPlayer = (L2PcInstance) targetChar;
final byte lvl = Byte.parseByte(val);
if ((lvl >= 1) && (lvl <= Experience.MAX_LEVEL))
{
final long pXp = targetPlayer.getExp();
final long tXp = Experience.LEVEL[lvl];
if (pXp > tXp)
{
targetPlayer.removeExpAndSp(pXp - tXp, 0);
}
else if (pXp < tXp)
{
targetPlayer.addExpAndSp(tXp - pXp, 0);
}
}
else
{
activeChar.sendMessage("You must specify level between 1 and " + Experience.MAX_LEVEL + ".");
return false;
}
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("You must specify level between 1 and " + Experience.MAX_LEVEL + ".");
return false;
}
}
return true;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
*/
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +1,169 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.gameserverpackets.ServerStatus;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* This class handles the admin commands that acts on the login
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
*/
public class AdminLogin implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminDelete.class.getName());
private static String[] _adminCommands =
{
"admin_server_gm_only",
"admin_server_all",
"admin_server_max_player",
"admin_server_list_clock",
"admin_server_login"
};
private static final int REQUIRED_LEVEL = Config.GM_ACCESSLEVEL;
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (activeChar.getAccessLevel() < REQUIRED_LEVEL)
{
return false;
}
}
if (command.equals("admin_server_gm_only"))
{
gmOnly();
activeChar.sendMessage("Server is now GM only");
showWindow(activeChar);
}
else if (command.equals("admin_server_all"))
{
AllowToAll();
activeChar.sendMessage("Server is not GM only anymore");
showWindow(activeChar);
}
else if (command.startsWith("admin_server_max_player"))
{
final StringTokenizer st = new StringTokenizer(command);
if (st.countTokens() > 1)
{
st.nextToken();
final String number = st.nextToken();
try
{
LoginServerThread.getInstance().setMaxPlayer(new Integer(number).intValue());
activeChar.sendMessage("maxPlayer set to " + new Integer(number).intValue());
showWindow(activeChar);
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Max players must be a number.");
}
}
else
{
activeChar.sendMessage("Format is server_max_player <max>");
}
}
else if (command.startsWith("admin_server_list_clock"))
{
final StringTokenizer st = new StringTokenizer(command);
if (st.countTokens() > 1)
{
st.nextToken();
final String mode = st.nextToken();
if (mode.equals("on"))
{
LoginServerThread.getInstance().sendServerStatus(ServerStatus.SERVER_LIST_CLOCK, ServerStatus.ON);
activeChar.sendMessage("A clock will now be displayed next to the server name");
Config.SERVER_LIST_CLOCK = true;
showWindow(activeChar);
}
else if (mode.equals("off"))
{
LoginServerThread.getInstance().sendServerStatus(ServerStatus.SERVER_LIST_CLOCK, ServerStatus.OFF);
Config.SERVER_LIST_CLOCK = false;
activeChar.sendMessage("The clock will not be displayed");
showWindow(activeChar);
}
else
{
activeChar.sendMessage("Format is server_list_clock <on/off>");
}
}
else
{
activeChar.sendMessage("Format is server_list_clock <on/off>");
}
}
else if (command.equals("admin_server_login"))
{
showWindow(activeChar);
}
return true;
}
private void showWindow(L2PcInstance activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/admin/login.htm");
html.replace("%server_name%", LoginServerThread.getInstance().getServerName());
html.replace("%status%", LoginServerThread.getInstance().getStatusString());
html.replace("%clock%", String.valueOf(Config.SERVER_LIST_CLOCK));
html.replace("%brackets%", String.valueOf(Config.SERVER_LIST_BRACKET));
html.replace("%max_players%", String.valueOf(LoginServerThread.getInstance().getMaxPlayer()));
activeChar.sendPacket(html);
}
private void AllowToAll()
{
LoginServerThread.getInstance().setServerStatus(ServerStatus.STATUS_AUTO);
Config.SERVER_GMONLY = false;
}
private void gmOnly()
{
LoginServerThread.getInstance().setServerStatus(ServerStatus.STATUS_GM_ONLY);
Config.SERVER_GMONLY = true;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
*/
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,173 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.SevenSigns;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.AutoSpawnHandler;
import com.l2jmobius.gameserver.model.AutoSpawnHandler.AutoSpawnInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Admin Command Handler for Mammon NPCs
* @author Tempy
*/
public class AdminMammon implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_mammon_find",
"admin_mammon_respawn",
"admin_list_spawns",
"admin_msg"
};
private static final int REQUIRED_LEVEL = Config.GM_MENU;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final boolean _isSealValidation = SevenSigns.getInstance().isSealValidationPeriod();
int npcId = 0;
int teleportIndex = -1;
final AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false);
final AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false);
if (command.startsWith("admin_mammon_find"))
{
try
{
if (command.length() > 17)
{
teleportIndex = Integer.parseInt(command.substring(18));
}
}
catch (final Exception NumberFormatException)
{
activeChar.sendMessage("Command format is //mammon_find <teleportIndex> (where 1 = Blacksmith, 2 = Merchant)");
}
if (!_isSealValidation)
{
activeChar.sendMessage("The competition period is currently in effect.");
return true;
}
final L2NpcInstance[] blackInst = blackSpawnInst.getNPCInstanceList();
final L2NpcInstance[] merchInst = merchSpawnInst.getNPCInstanceList();
if (blackInst.length > 0)
{
activeChar.sendMessage("Blacksmith of Mammon: " + blackInst[0].getX() + " " + blackInst[0].getY() + " " + blackInst[0].getZ());
if (teleportIndex == 0)
{
activeChar.teleToLocation(blackInst[0].getX(), blackInst[0].getY(), blackInst[0].getZ(), true);
}
}
if (merchInst.length > 0)
{
activeChar.sendMessage("Merchant of Mammon: " + merchInst[0].getX() + " " + merchInst[0].getY() + " " + merchInst[0].getZ());
if (teleportIndex == 1)
{
activeChar.teleToLocation(merchInst[0].getX(), merchInst[0].getY(), merchInst[0].getZ(), true);
}
}
}
else if (command.startsWith("admin_mammon_respawn"))
{
if (!_isSealValidation)
{
activeChar.sendMessage("The competition period is currently in effect.");
return true;
}
final long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst);
final long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst);
activeChar.sendMessage("The Merchant of Mammon will respawn in " + (merchRespawn / 60000) + " minute(s).");
activeChar.sendMessage("The Blacksmith of Mammon will respawn in " + (blackRespawn / 60000) + " minute(s).");
}
else if (command.startsWith("admin_list_spawns"))
{
try
{ // admin_list_spawns x[xxxx] x[xx]
final String[] params = command.split(" ");
npcId = Integer.parseInt(params[1]);
if (params.length > 2)
{
teleportIndex = Integer.parseInt(params[2]);
}
}
catch (final Exception e)
{
activeChar.sendPacket(SystemMessage.sendString("Command format is //list_spawns <NPC_ID> <TELE_INDEX>"));
}
SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex);
}
// Used for testing SystemMessage IDs - Use //msg <ID>
else if (command.startsWith("admin_msg"))
{
int msgId = -1;
try
{
msgId = Integer.parseInt(command.substring(10).trim());
}
catch (final Exception e)
{
activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>");
return true;
}
activeChar.sendPacket(new SystemMessage(msgId));
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,238 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
import com.l2jmobius.gameserver.instancemanager.CastleManorManager.CropProcure;
import com.l2jmobius.gameserver.instancemanager.CastleManorManager.SeedProduction;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import javolution.text.TextBuilder;
import javolution.util.FastList;
/**
* Admin comand handler for Manor System This class handles following admin commands: - manor_info = shows info about current manor state - manor_approve = approves settings for the next manor period - manor_setnext = changes manor settings to the next day's - manor_reset castle = resets all manor
* data for specified castle (or all) - manor_setmaintenance = sets manor system under maintenance mode - manor_save = saves all manor data into database - manor_disable = disables manor system
* @author l3x
*/
public class AdminManor implements IAdminCommandHandler
{
private static final String[] _adminCommands =
{
"admin_manor",
"admin_manor_approve",
"admin_manor_setnext",
"admin_manor_reset",
"admin_manor_setmaintenance",
"admin_manor_save",
"admin_manor_disable"
};
private static final int REQUIRED_LEVEL = Config.GM_MENU;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final StringTokenizer st = new StringTokenizer(command);
command = st.nextToken();
if (command.equals("admin_manor"))
{
showMainPage(activeChar);
}
else if (command.equals("admin_manor_setnext"))
{
CastleManorManager.getInstance().setNextPeriod();
CastleManorManager.getInstance().setNewManorRefresh();
CastleManorManager.getInstance().updateManorRefresh();
activeChar.sendMessage("Manor System: set to next period");
showMainPage(activeChar);
}
else if (command.equals("admin_manor_approve"))
{
CastleManorManager.getInstance().approveNextPeriod();
CastleManorManager.getInstance().setNewPeriodApprove();
CastleManorManager.getInstance().updatePeriodApprove();
activeChar.sendMessage("Manor System: next period approved");
showMainPage(activeChar);
}
else if (command.equals("admin_manor_reset"))
{
int castleId = 0;
try
{
castleId = Integer.parseInt(st.nextToken());
}
catch (final Exception e)
{
}
if (castleId > 0)
{
final Castle castle = CastleManager.getInstance().getCastleById(castleId);
castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_CURRENT);
castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_NEXT);
castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_CURRENT);
castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_NEXT);
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
{
castle.saveCropData();
castle.saveSeedData();
}
activeChar.sendMessage("Manor data for " + castle.getName() + " was nulled");
}
else
{
for (final Castle castle : CastleManager.getInstance().getCastles())
{
castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_CURRENT);
castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_NEXT);
castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_CURRENT);
castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_NEXT);
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
{
castle.saveCropData();
castle.saveSeedData();
}
}
activeChar.sendMessage("Manor data was nulled");
}
showMainPage(activeChar);
}
else if (command.equals("admin_manor_setmaintenance"))
{
final boolean mode = CastleManorManager.getInstance().isUnderMaintenance();
CastleManorManager.getInstance().setUnderMaintenance(!mode);
if (mode)
{
activeChar.sendMessage("Manor System: not under maintenance");
}
else
{
activeChar.sendMessage("Manor System: under maintenance");
}
showMainPage(activeChar);
}
else if (command.equals("admin_manor_save"))
{
CastleManorManager.getInstance().save();
activeChar.sendMessage("Manor System: all data saved");
showMainPage(activeChar);
}
else if (command.equals("admin_manor_disable"))
{
final boolean mode = CastleManorManager.getInstance().isDisabled();
CastleManorManager.getInstance().setDisabled(!mode);
if (mode)
{
activeChar.sendMessage("Manor System: enabled");
}
else
{
activeChar.sendMessage("Manor System: disabled");
}
showMainPage(activeChar);
}
return true;
}
private String formatTime(long millis)
{
String s = "";
int secs = (int) millis / 1000;
int mins = secs / 60;
secs -= mins * 60;
final int hours = mins / 60;
mins -= hours * 60;
if (hours > 0)
{
s += hours + ":";
}
s += mins + ":";
s += secs;
return s;
}
private void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><font color=\"LEVEL\"> [Manor System] </font></center><br>");
replyMSG.append("<table width=\"100%\"><tr><td>");
replyMSG.append("Disabled: " + (CastleManorManager.getInstance().isDisabled() ? "yes" : "no") + "</td><td>");
replyMSG.append("Under Maintenance: " + (CastleManorManager.getInstance().isUnderMaintenance() ? "yes" : "no") + "</td></tr><tr><td>");
replyMSG.append("Time to refresh: " + formatTime(CastleManorManager.getInstance().getMillisToManorRefresh()) + "</td><td>");
replyMSG.append("Time to approve: " + formatTime(CastleManorManager.getInstance().getMillisToNextPeriodApprove()) + "</td></tr>");
replyMSG.append("</table>");
replyMSG.append("<center><table><tr><td>");
replyMSG.append("<button value=\"Set Next\" action=\"bypass -h admin_manor_setnext\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Approve Next\" action=\"bypass -h admin_manor_approve\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr><tr><td>");
replyMSG.append("<button value=\"" + (CastleManorManager.getInstance().isUnderMaintenance() ? "Set normal" : "Set mainteance") + "\" action=\"bypass -h admin_manor_setmaintenance\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"" + (CastleManorManager.getInstance().isDisabled() ? "Enable" : "Disable") + "\" action=\"bypass -h admin_manor_disable\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr><tr><td>");
replyMSG.append("<button value=\"Refresh\" action=\"bypass -h admin_manor\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Back\" action=\"bypass -h admin_admin\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table></center>");
replyMSG.append("<br><center>Castle Information:<table width=\"100%\">");
replyMSG.append("<tr><td></td><td>Current Period</td><td>Next Period</td></tr>");
for (final Castle c : CastleManager.getInstance().getCastles())
{
replyMSG.append("<tr><td>" + c.getName() + "</td>" + "<td>" + c.getManorCost(CastleManorManager.PERIOD_CURRENT) + "a</td>" + "<td>" + c.getManorCost(CastleManorManager.PERIOD_NEXT) + "a</td>" + "</tr>");
}
replyMSG.append("</table><br>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,274 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - handles ever admin menu command
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminMenu implements IAdminCommandHandler
{
// private static final Logger _log = Logger.getLogger(AdminMenu.class.getName());
private static String[] _adminCommands =
{
"admin_char_manage",
"admin_teleport_character_to_menu",
"admin_recall_char_menu",
"admin_goto_char_menu",
"admin_kick_menu",
"admin_kill_menu",
"admin_ban_menu",
"admin_unban_menu"
};
private static final int REQUIRED_LEVEL = Config.GM_ACCESSLEVEL;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (command.equals("admin_char_manage"))
{
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
else if (command.startsWith("admin_teleport_character_to_menu"))
{
final String[] data = command.split(" ");
if (data.length == 5)
{
final String playerName = data[1];
final int x = Integer.parseInt(data[2]);
final int y = Integer.parseInt(data[3]);
final int z = Integer.parseInt(data[4]);
final L2PcInstance player = L2World.getInstance().getPlayer(playerName);
if (player != null)
{
teleportCharacter(player, x, y, z, activeChar);
}
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
else if (command.startsWith("admin_recall_char_menu"))
{
try
{
final String targetName = command.substring(23);
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
teleportCharacter(player, x, y, z, activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_goto_char_menu"))
{
try
{
final String targetName = command.substring(21);
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
teleportToCharacter(activeChar, player);
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.equals("admin_kill_menu"))
{
handleKill(activeChar);
}
else if (command.startsWith("admin_kick_menu"))
{
final StringTokenizer st = new StringTokenizer(command);
// System.out.println("Tokens: "+st.countTokens());
if (st.countTokens() > 1)
{
st.nextToken();
final String player = st.nextToken();
// System.out.println("Player1 "+player);
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
final SystemMessage sm = new SystemMessage(614);
if (plyr != null)
{
// System.out.println("Player2 "+plyr.getName());
plyr.logout();
sm.addString("You kicked " + plyr.getName() + " from the game.");
}
else
{
sm.addString("Player " + player + " was not found in the game.");
}
activeChar.sendPacket(sm);
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
else if (command.startsWith("admin_ban_menu"))
{
final StringTokenizer st = new StringTokenizer(command);
if (st.countTokens() > 1)
{
st.nextToken();
final String player = st.nextToken();
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
if (plyr != null)
{
plyr.logout();
LoginServerThread.getInstance().sendAccessLevel(plyr.getAccountName(), -100);
activeChar.sendMessage("A ban request has been sent for account " + plyr.getAccountName() + ".");
}
else
{
activeChar.sendMessage("Target is not online.");
}
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
else if (command.startsWith("admin_unban_menu"))
{
final StringTokenizer st = new StringTokenizer(command);
if (st.countTokens() > 1)
{
st.nextToken();
final String player = st.nextToken();
LoginServerThread.getInstance().sendAccessLevel(player, 0);
activeChar.sendMessage("An unban request has been sent for account " + player + ".");
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleKill(L2PcInstance activeChar)
{
handleKill(activeChar, null);
}
private void handleKill(L2PcInstance activeChar, String player)
{
L2Object obj = activeChar.getTarget();
if (player != null)
{
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
if (plyr != null)
{
obj = plyr;
final SystemMessage sm = new SystemMessage(614);
sm.addString("You killed " + plyr.getName() + ".");
activeChar.sendPacket(sm);
}
}
if ((obj != null) && (obj instanceof L2Character))
{
final L2Character target = (L2Character) obj;
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar);
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
private void teleportCharacter(L2PcInstance player, int x, int y, int z, L2PcInstance activeChar)
{
if (player != null)
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Admin is teleporting you.");
player.sendPacket(sm);
player.teleToLocation(x, y, z, true);
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
{
L2PcInstance player = null;
if ((target != null) && (target instanceof L2PcInstance))
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
if (player.getObjectId() == activeChar.getObjectId())
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("You cannot self teleport.");
activeChar.sendPacket(sm);
}
else
{
final int x = player.getX();
final int y = player.getY();
final int z = player.getZ();
activeChar.teleToLocation(x, y, z, true);
final SystemMessage sm = new SystemMessage(614);
sm.addString("You have teleported to character " + player.getName() + ".");
activeChar.sendPacket(sm);
}
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
}
}

View File

@@ -0,0 +1,660 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.NpcTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.MobGroup;
import com.l2jmobius.gameserver.model.MobGroupTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SetupGauge;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* @author littlecrow Admin commands handler for controllable mobs
*/
public class AdminMobGroup implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_mobmenu",
"admin_mobgroup_list",
"admin_mobgroup_create",
"admin_mobgroup_remove",
"admin_mobgroup_delete",
"admin_mobgroup_spawn",
"admin_mobgroup_unspawn",
"admin_mobgroup_kill",
"admin_mobgroup_idle",
"admin_mobgroup_attack",
"admin_mobgroup_rnd",
"admin_mobgroup_return",
"admin_mobgroup_follow",
"admin_mobgroup_casting",
"admin_mobgroup_nomove",
"admin_mobgroup_attackgrp",
"admin_mobgroup_invul",
"admin_mobinst"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_mobmenu"))
{
AdminHelpPage.showHelpPage(activeChar, "mobgroup.htm");
}
else if (command.equals("admin_mobinst"))
{
AdminHelpPage.showHelpPage(activeChar, "mobgrouphelp.htm");
}
else if (command.equals("admin_mobgroup_list"))
{
showGroupList(activeChar);
}
else if (command.startsWith("admin_mobgroup_create"))
{
createGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_delete") || command.startsWith("admin_mobgroup_remove"))
{
removeGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_spawn"))
{
spawnGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_unspawn"))
{
unspawnGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_kill"))
{
killGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_attackgrp"))
{
attackGrp(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_attack"))
{
if (activeChar.getTarget() instanceof L2Character)
{
final L2Character target = (L2Character) activeChar.getTarget();
attack(command, activeChar, target);
}
}
else if (command.startsWith("admin_mobgroup_rnd"))
{
setNormal(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_idle"))
{
idle(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_return"))
{
returnToChar(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_follow"))
{
follow(command, activeChar, activeChar);
}
else if (command.startsWith("admin_mobgroup_casting"))
{
setCasting(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_nomove"))
{
noMove(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_invul"))
{
invul(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_teleport"))
{
teleportGroup(command, activeChar);
}
return true;
}
private void returnToChar(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.returnGroup(activeChar);
}
private void idle(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setIdleMode();
}
private void setNormal(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setAttackRandom();
}
private void attack(String command, L2PcInstance activeChar, L2Character target)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setAttackTarget(target);
}
private void follow(String command, L2PcInstance activeChar, L2Character target)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setFollowMode(target);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void createGroup(String command, L2PcInstance activeChar)
{
int groupId;
int templateId;
int mobCount;
try
{
final String[] cmdParams = command.split(" ");
groupId = Integer.parseInt(cmdParams[1]);
templateId = Integer.parseInt(cmdParams[2]);
mobCount = Integer.parseInt(cmdParams[3]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
if (MobGroupTable.getInstance().getGroup(groupId) != null)
{
activeChar.sendMessage("Mob group " + groupId + " already exists.");
return;
}
final L2NpcTemplate template = NpcTable.getInstance().getTemplate(templateId);
if (template == null)
{
activeChar.sendMessage("Invalid NPC ID specified.");
return;
}
final MobGroup group = new MobGroup(groupId, template, mobCount);
MobGroupTable.getInstance().addGroup(groupId, group);
activeChar.sendMessage("Mob group " + groupId + " created.");
}
private void removeGroup(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
group.unspawnGroup();
if (MobGroupTable.getInstance().removeGroup(groupId))
{
activeChar.sendMessage("Mob group " + groupId + " unspawned and removed.");
}
}
private void spawnGroup(String command, L2PcInstance activeChar)
{
int groupId;
boolean topos = false;
int posx = 0;
int posy = 0;
int posz = 0;
try
{
final String[] cmdParams = command.split(" ");
groupId = Integer.parseInt(cmdParams[1]);
try
{ // we try to get a position
posx = Integer.parseInt(cmdParams[2]);
posy = Integer.parseInt(cmdParams[3]);
posz = Integer.parseInt(cmdParams[4]);
topos = true;
}
catch (final Exception e)
{
// no position given
}
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
if (topos)
{
group.spawnGroup(posx, posy, posz);
}
else
{
group.spawnGroup(activeChar);
}
activeChar.sendMessage("Mob group " + groupId + " spawned.");
}
private void unspawnGroup(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
group.unspawnGroup();
activeChar.sendMessage("Mob group " + groupId + " unspawned.");
}
private void killGroup(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
group.killGroup(activeChar);
}
private void setCasting(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setCastMode();
}
private void noMove(String command, L2PcInstance activeChar)
{
int groupId;
String enabled;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
enabled = command.split(" ")[2];
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
if (enabled.equalsIgnoreCase("on") || enabled.equalsIgnoreCase("true"))
{
group.setNoMoveMode(true);
}
else if (enabled.equalsIgnoreCase("off") || enabled.equalsIgnoreCase("false"))
{
group.setNoMoveMode(false);
}
else
{
activeChar.sendMessage("Incorrect command arguments.");
}
}
private void doAnimation(L2PcInstance activeChar)
{
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, 1008, 1, 4000, 0), 2250000/* 1500 */);
activeChar.sendPacket(new SetupGauge(0, 4000));
}
private void attackGrp(String command, L2PcInstance activeChar)
{
int groupId;
int othGroupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
othGroupId = Integer.parseInt(command.split(" ")[2]);
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
final MobGroup othGroup = MobGroupTable.getInstance().getGroup(othGroupId);
if (othGroup == null)
{
activeChar.sendMessage("Incorrect target group.");
return;
}
group.setAttackGroup(othGroup);
}
private void invul(String command, L2PcInstance activeChar)
{
int groupId;
String enabled;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
enabled = command.split(" ")[2];
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
if (enabled.equalsIgnoreCase("on") || enabled.equalsIgnoreCase("true"))
{
group.setInvul(true);
}
else if (enabled.equalsIgnoreCase("off") || enabled.equalsIgnoreCase("false"))
{
group.setInvul(false);
}
else
{
activeChar.sendMessage("Incorrect command arguments.");
}
}
private void teleportGroup(String command, L2PcInstance activeChar)
{
int groupId;
String targetPlayerStr = null;
L2PcInstance targetPlayer = null;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
targetPlayerStr = command.split(" ")[2];
if (targetPlayerStr != null)
{
targetPlayer = L2World.getInstance().getPlayer(targetPlayerStr);
}
if (targetPlayer == null)
{
targetPlayer = activeChar;
}
}
catch (final Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.teleportGroup(activeChar);
}
private void showGroupList(L2PcInstance activeChar)
{
final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();
activeChar.sendMessage("======= <Mob Groups> =======");
for (final MobGroup mobGroup : mobGroupList)
{
activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().npcId + " (" + mobGroup.getStatus() + ")");
}
activeChar.sendPacket(new SystemMessage(SystemMessage.FRIEND_LIST_FOOT));
}
}

View File

@@ -0,0 +1,175 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.MonsterRace;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
import com.l2jmobius.gameserver.network.serverpackets.MonRaceInfo;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - invul = turns invulnerability on/off
* @version $Revision: 1.1.6.4 $ $Date: 2005/04/11 10:06:00 $
*/
public class AdminMonsterRace implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminMonsterRace.class.getName());
private static String[] _adminCommands =
{
"admin_mons"
};
private static final int REQUIRED_LEVEL = Config.GM_MONSTERRACE;
protected static int state = -1;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equalsIgnoreCase("admin_mons"))
{
handleSendPacket(activeChar);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleSendPacket(L2PcInstance activeChar)
{
/*
* -1 0 to initial the race 0 15322 to start race 13765 -1 in middle of race -1 0 to end the race 8003 to 8027
*/
final int[][] codes =
{
{
-1,
0
},
{
0,
15322
},
{
13765,
-1
},
{
-1,
0
}
};
final MonsterRace race = MonsterRace.getInstance();
if (state == -1)
{
state++;
race.newRace();
race.newSpeeds();
final MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
}
else if (state == 0)
{
state++;
final SystemMessage sm = new SystemMessage(824);
sm.addNumber(0);
activeChar.sendPacket(sm);
final PlaySound SRace = new PlaySound(1, "S_Race", 0, 0, 0, 0, 0);
activeChar.sendPacket(SRace);
activeChar.broadcastPacket(SRace);
final PlaySound SRace2 = new PlaySound(0, "ItemSound2.race_start", 1, 121209259, 12125, 182487, -3559);
activeChar.sendPacket(SRace2);
activeChar.broadcastPacket(SRace2);
final MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(codes, activeChar), 5000);
}
}
class RunRace implements Runnable
{
private final int[][] codes;
private final L2PcInstance activeChar;
public RunRace(int[][] pCodes, L2PcInstance pActiveChar)
{
codes = pCodes;
activeChar = pActiveChar;
}
@Override
public void run()
{
final MonRaceInfo spk = new MonRaceInfo(codes[2][0], codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(activeChar), 30000);
}
}
class RunEnd implements Runnable
{
private final L2PcInstance activeChar;
public RunEnd(L2PcInstance pActiveChar)
{
activeChar = pActiveChar;
}
@Override
public void run()
{
DeleteObject obj = null;
for (int i = 0; i < 8; i++)
{
obj = new DeleteObject(MonsterRace.getInstance().getMonsters()[i]);
activeChar.sendPacket(obj);
activeChar.broadcastPacket(obj);
}
state = -1;
}
}
}

View File

@@ -0,0 +1,247 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.AdminForgePacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import javolution.text.TextBuilder;
/**
* This class handles commands for gm to forge packets
* @author Maktakien
*/
public class AdminPForge implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminKick.class.getName());
private static String[] _adminCommands =
{
"admin_forge",
"admin_forge2",
"admin_forge3"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_forge"))
{
showMainPage(activeChar);
}
else if (command.startsWith("admin_forge2"))
{
try
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
final String format = st.nextToken();
showPage2(activeChar, format);
}
catch (final Exception ex)
{
}
}
else if (command.startsWith("admin_forge3"))
{
try
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
String format = st.nextToken();
boolean broadcast = false;
if (format.toLowerCase().equals("broadcast"))
{
format = st.nextToken();
broadcast = true;
}
final AdminForgePacket sp = new AdminForgePacket();
for (int i = 0; i < format.length(); i++)
{
String val = st.nextToken();
if (val.toLowerCase().equals("$objid"))
{
val = String.valueOf(activeChar.getObjectId());
}
else if (val.toLowerCase().equals("$tobjid"))
{
val = String.valueOf(activeChar.getTarget().getObjectId());
}
else if (val.toLowerCase().equals("$bobjid"))
{
if (activeChar.getBoat() != null)
{
val = String.valueOf(activeChar.getBoat().getObjectId());
}
}
else if (val.toLowerCase().equals("$clanid"))
{
val = String.valueOf(activeChar.getCharId());
}
else if (val.toLowerCase().equals("$allyid"))
{
val = String.valueOf(activeChar.getAllyId());
}
else if (val.toLowerCase().equals("$tclanid"))
{
val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getCharId());
}
else if (val.toLowerCase().equals("$tallyid"))
{
val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getAllyId());
}
else if (val.toLowerCase().equals("$x"))
{
val = String.valueOf(activeChar.getX());
}
else if (val.toLowerCase().equals("$y"))
{
val = String.valueOf(activeChar.getY());
}
else if (val.toLowerCase().equals("$z"))
{
val = String.valueOf(activeChar.getZ());
}
else if (val.toLowerCase().equals("$heading"))
{
val = String.valueOf(activeChar.getHeading());
}
else if (val.toLowerCase().equals("$tx"))
{
val = String.valueOf(activeChar.getTarget().getX());
}
else if (val.toLowerCase().equals("$ty"))
{
val = String.valueOf(activeChar.getTarget().getY());
}
else if (val.toLowerCase().equals("$tz"))
{
val = String.valueOf(activeChar.getTarget().getZ());
}
else if (val.toLowerCase().equals("$theading"))
{
val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getHeading());
}
sp.addPart(format.getBytes()[i], val);
}
if (broadcast == true)
{
activeChar.broadcastPacket(sp);
}
else
{
activeChar.sendPacket(sp);
}
showPage3(activeChar, format, command);
}
catch (final Exception ex)
{
ex.printStackTrace();
}
}
return true;
}
public void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center>L2J Forge Panel</center><br>");
replyMSG.append("Format:<edit var=\"format\" width=100><br>");
replyMSG.append("<button value=\"Step2\" action=\"bypass -h admin_forge2 $format\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>");
replyMSG.append("Only c h d f s b or x work<br>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showPage3(L2PcInstance activeChar, String format, String command)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center>L2J Forge Panel 3</center><br>");
replyMSG.append("GG !! If you can see this, there was no critical :)<br>");
replyMSG.append("and packet (" + format + ") was sent<br><br>");
replyMSG.append("<button value=\"Try again ?\" action=\"bypass -h admin_forge\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("<br><br>Debug: cmd string :" + command + "<br>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showPage2(L2PcInstance activeChar, String format)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center>L2J Forge Panel 2</center><br>Format:" + format);
replyMSG.append("<br>No spaces in values please ;)<br>Decimal values for c h d, a float (with point) for f, a string for s and for x/b the hexadecimal value");
replyMSG.append("<br>Values<br>");
for (int i = 0; i < format.length(); i++)
{
replyMSG.append(format.charAt(i) + " : <edit var=\"v" + i + "\" width=100> <br>");
}
replyMSG.append("<br><button value=\"Send\" action=\"bypass -h admin_forge3 " + format);
for (int i = 0; i < format.length(); i++)
{
replyMSG.append(" $v" + i);
}
replyMSG.append("\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("<br><button value=\"Broadcast\" action=\"bypass -h admin_forge3 broadcast " + format);
for (int i = 0; i < format.length(); i++)
{
replyMSG.append(" $v" + i);
}
replyMSG.append("\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,121 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.pathfinding.AbstractNodeLoc;
import com.l2jmobius.gameserver.pathfinding.PathFinding;
public class AdminPathNode implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_pn_info",
"admin_show_path",
"admin_path_debug",
"admin_show_pn",
"admin_find_path"
};
private static final int REQUIRED_LEVEL = Config.GM_CREATE_NODES;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
// Config.NEW_NODE_ID
if (command.equals("admin_pn_info"))
{
final String[] info = PathFinding.getInstance().getStat();
if (info == null)
{
activeChar.sendMessage("Not supported.");
}
else
{
for (final String msg : info)
{
activeChar.sendMessage(msg);
}
}
}
else if (command.equals("admin_show_path"))
{
}
else if (command.equals("admin_path_debug"))
{
}
else if (command.equals("admin_show_pn"))
{
}
else if (command.equals("admin_find_path"))
{
if (Config.GEODATA < 2)
{
activeChar.sendMessage("PathFinding has not been enabled.");
return true;
}
if (activeChar.getTarget() != null)
{
final List<AbstractNodeLoc> path = PathFinding.getInstance().findPath(activeChar.getX(), activeChar.getY(), activeChar.getZ(), activeChar.getTarget().getX(), activeChar.getTarget().getY(), activeChar.getTarget().getZ(), true);
if (path == null)
{
activeChar.sendMessage("No Route!");
return true;
}
for (final AbstractNodeLoc a : path)
{
activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
}
}
else
{
activeChar.sendMessage("No Target!");
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles commands for GMs to respond to petitions.
* @author Tempy
*/
public class AdminPetition implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_view_petitions",
"admin_view_petition",
"admin_accept_petition",
"admin_reject_petition",
"admin_reset_petitions"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
int petitionId = -1;
try
{
petitionId = Integer.parseInt(command.split(" ")[1]);
}
catch (final Exception e)
{
}
if (command.equals("admin_view_petitions"))
{
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
}
else if (command.startsWith("admin_view_petition"))
{
PetitionManager.getInstance().viewPetition(activeChar, petitionId);
}
else if (command.startsWith("admin_accept_petition"))
{
if (PetitionManager.getInstance().isPlayerInConsultation(activeChar))
{
activeChar.sendMessage("You may only deal with one active petition at a time.");
return true;
}
if (PetitionManager.getInstance().isPetitionInProcess(petitionId))
{
activeChar.sendMessage("The petition has already answered.");
return true;
}
if (!PetitionManager.getInstance().acceptPetition(activeChar, petitionId))
{
activeChar.sendMessage("Invalid petition specified or error occurred.");
}
}
else if (command.startsWith("admin_reject_petition"))
{
if (!PetitionManager.getInstance().rejectPetition(activeChar, petitionId))
{
activeChar.sendMessage("Invalid petition specified or error occurred.");
}
}
else if (command.equals("admin_reset_petitions"))
{
if (PetitionManager.getInstance().isPetitionInProcess())
{
activeChar.sendMessage("You cannot clear the petition queue when a petition is being dealt with.");
return false;
}
PetitionManager.getInstance().clearPendingPetitions();
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,185 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.ClanTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import javolution.text.TextBuilder;
/**
* Pledge Manipulation //pledge <create|dismiss>
*/
public class AdminPledge implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminPledge.class.getName());
private static String[] _adminCommands =
{
"admin_pledge"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!activeChar.isGM() || (activeChar.getAccessLevel() < Config.GM_ACCESSLEVEL))
{
return false;
}
}
if (command.startsWith("admin_pledge"))
{
String action = null;
String parameter = null;
GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
final StringTokenizer st = new StringTokenizer(command);
try
{
st.nextToken();
action = st.nextToken(); // create|dismiss|setlevel
parameter = st.nextToken(); // clanname|nothing|nothing|level
}
catch (final NoSuchElementException nse)
{
}
if (action != null)
{
if (activeChar.getTarget() == null)
{
activeChar.sendMessage("Please select a target.");
return false;
}
if (!(activeChar.getTarget() instanceof L2PcInstance))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
return false;
}
final L2PcInstance target = (L2PcInstance) activeChar.getTarget();
if (parameter == null)
{
activeChar.sendMessage("Usage: //pledge <setlevel> <number>");
}
else if (action.equals("create"))
{
try
{
final long time = target.getClanCreateExpiryTime();
target.setClanCreateExpiryTime(0);
final L2Clan clan = ClanTable.getInstance().createClan(target, parameter);
if (clan != null)
{
activeChar.sendMessage("Clan " + parameter + " created! Leader: " + target.getName());
}
else
{
target.setClanCreateExpiryTime(time);
activeChar.sendMessage("There was a problem while creating the clan.");
}
}
catch (final Exception e)
{
_log.warning("Error creating pledge by GM command: " + e);
}
}
else if (!target.isClanLeader())
{
activeChar.sendMessage("Target is not a clan leader.");
showMainPage(activeChar);
return false;
}
else if (action.equals("dismiss"))
{
ClanTable.getInstance().destroyClan(target.getClanId());
if (target.getClan() == null)
{
activeChar.sendMessage("Clan disbanded.");
}
else
{
activeChar.sendMessage("There was a problem while destroying the clan.");
}
}
else if (action.equals("setlevel"))
{
final int level = Integer.parseInt(parameter);
if ((level >= 0) && (level < 6))
{
target.getClan().changeLevel(level);
activeChar.sendMessage("You set level " + level + " for clan " + target.getClan().getName());
}
else
{
activeChar.sendMessage("Incorrect level.");
}
}
}
}
showMainPage(activeChar);
return true;
}
public void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<center><table width=260><tr><td width=40>");
replyMSG.append("<button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</td><td width=180>");
replyMSG.append("<center>Clan Management</center>");
replyMSG.append("</td><td width=40>");
replyMSG.append("</td></tr></table></center><br>");
replyMSG.append("<center>Create / Destroy / Level 0-5:</center>");
replyMSG.append("<center><edit var=\"menu_command\" width=100 height=15></center><br>");
replyMSG.append("<center><table><tr><td>");
replyMSG.append("<button value=\"Create\" action=\"bypass -h admin_pledge create $menu_command\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Delete\" action=\"bypass -h admin_pledge dismiss $menu_command\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"SetLevel\" action=\"bypass -h admin_pledge setlevel $menu_command\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,113 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SetupGauge;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands: - delete = deletes target
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
*/
public class AdminPolymorph implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminDelete.class.getName());
private static String[] _adminCommands =
{
"admin_polymorph"
};
private static final int REQUIRED_LEVEL = Config.GM_NPC_EDIT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_polymorph"))
{
final StringTokenizer st = new StringTokenizer(command);
try
{
st.nextToken();
final String type = st.nextToken();
final String id = st.nextToken();
final L2Object target = activeChar.getTarget();
doPolymorph(activeChar, target, id, type);
}
catch (final Exception e)
{
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void doPolymorph(L2PcInstance activeChar, L2Object obj, String id, String type)
{
if (obj != null)
{
obj.getPoly().setPolyInfo(type, id);
// animation
if (obj instanceof L2Character)
{
final L2Character Char = (L2Character) obj;
final MagicSkillUse msk = new MagicSkillUse(Char, 1008, 1, 4000, 0);
Char.broadcastPacket(msk);
final SetupGauge sg = new SetupGauge(0, 4000);
Char.sendPacket(sg);
}
// end of animation
// L2Character target = (L2Character) obj;
obj.decayMe();
obj.spawnMe(obj.getX(), obj.getY(), obj.getZ());
}
else
{
final SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
}
}
}

View File

@@ -0,0 +1,166 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.io.File;
import javax.script.ScriptException;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.scripting.L2ScriptEngineManager;
public class AdminQuest implements IAdminCommandHandler
{
private static final int REQUIRED_LEVEL = Config.GM_TEST;
public static final String[] ADMIN_QUEST_COMMANDS =
{
"admin_quest_reload",
"admin_script_load"
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (activeChar == null)
{
return false;
}
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (activeChar.getAccessLevel() < REQUIRED_LEVEL)
{
return false;
}
}
// syntax will either be:
// //quest_reload <id>
// //quest_reload <questName>
// The questName MUST start with a non-numeric character for this to work,
// regardless which of the two formats is used.
// Example: //quest_reload orc_occupation_change_1
// Example: //quest_reload chests
// Example: //quest_reload SagasSuperclass
// Example: //quest_reload 12
if (command.startsWith("admin_quest_reload"))
{
final String[] parts = command.split(" ");
if (parts.length < 2)
{
activeChar.sendMessage("Syntax: //quest_reload <questFolder>.<questSubFolders...>.questName> or //quest_reload <id>");
}
else
{
// try the first param as id
try
{
final int questId = Integer.parseInt(parts[1]);
if (QuestManager.getInstance().reload(questId))
{
activeChar.sendMessage("Quest Reloaded Successfully.");
}
else
{
activeChar.sendMessage("Quest Reload Failed.");
}
}
catch (final NumberFormatException e)
{
if (QuestManager.getInstance().reload(parts[1]))
{
activeChar.sendMessage("Quest Reloaded Successfully.");
}
else
{
activeChar.sendMessage("Quest Reload Failed.");
}
}
}
}
// script load should NOT be used in place of reload. If a script is already loaded
// successfully, quest_reload ought to be used. The script_load command should only
// be used for scripts that failed to load altogether (eg. due to errors) or that
// did not at all exist during server boot. Using script_load to re-load a previously
// loaded script may cause unpredictable script flow, minor loss of data, and more.
// This provides a way to load new scripts without having to reboot the server.
else if (command.startsWith("admin_script_load"))
{
final String[] parts = command.split(" ");
if (parts.length < 2)
{
activeChar.sendMessage("Example: //script_load quests/SagasSuperclass/__init__.py");
}
else
{
final File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, parts[1]);
if (file.isFile())
{
try
{
L2ScriptEngineManager.getInstance().executeScript(file);
}
catch (final ScriptException ok)
{
try
{
// Jython path
L2ScriptEngineManager.getInstance().preConfigure();
L2ScriptEngineManager.getInstance().executeScript(file);
}
catch (final ScriptException e)
{
activeChar.sendMessage("Failed loading: " + parts[1]);
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
}
catch (final Exception e)
{
activeChar.sendMessage("Failed loading: " + parts[1]);
}
}
catch (final Exception e)
{
activeChar.sendMessage("Failed loading: " + parts[1]);
}
}
else
{
activeChar.sendMessage("File Not Found: " + parts[1]);
}
}
}
return true;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
*/
@Override
public String[] getAdminCommandList()
{
return ADMIN_QUEST_COMMANDS;
}
}

View File

@@ -0,0 +1,127 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - delete = deletes target
* @version $Revision: 1.1.2.6.2.3 $ $Date: 2005/04/11 10:05:59 $
*/
public class AdminRepairChar implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminRepairChar.class.getName());
private static String[] _adminCommands =
{
"admin_restore",
"admin_repair"
};
private static final int REQUIRED_LEVEL = Config.GM_CHAR_EDIT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
handleRepair(command);
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleRepair(String command)
{
final String[] parts = command.split(" ");
if (parts.length != 2)
{
return;
}
final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
try (Connection connection = L2DatabaseFactory.getInstance().getConnection())
{
try (PreparedStatement statement = connection.prepareStatement(cmd))
{
statement.setString(1, parts[1]);
statement.execute();
}
int objId = 0;
try (PreparedStatement statement = connection.prepareStatement("SELECT obj_id FROM characters where char_name=?"))
{
statement.setString(1, parts[1]);
try (ResultSet rset = statement.executeQuery())
{
if (rset.next())
{
objId = rset.getInt(1);
}
}
}
if (objId != 0)
{
try (PreparedStatement statement = connection.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=?"))
{
statement.setInt(1, objId);
statement.execute();
}
try (PreparedStatement statement = connection.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?"))
{
statement.setInt(1, objId);
statement.execute();
}
}
}
catch (final Exception e)
{
_log.log(Level.WARNING, "could not repair char:", e);
}
}
}

View File

@@ -0,0 +1,213 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
/**
* This class handles following admin commands: - res = resurrects target L2Character
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminRes implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminRes.class.getName());
private static String[] _adminCommands =
{
"admin_res",
"admin_res_monster"
};
private static final int REQUIRED_LEVEL = Config.GM_RES;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target";
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (command.startsWith("admin_res "))
{
handleRes(activeChar, command.split(" ")[1]);
}
else if (command.equals("admin_res"))
{
handleRes(activeChar);
}
else if (command.startsWith("admin_res_monster "))
{
handleNonPlayerRes(activeChar, command.split(" ")[1]);
}
else if (command.equals("admin_res_monster"))
{
handleNonPlayerRes(activeChar);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleRes(L2PcInstance activeChar)
{
handleRes(activeChar, null);
}
private void handleRes(L2PcInstance activeChar, String resParam)
{
L2Object obj = activeChar.getTarget();
if (resParam != null)
{
// Check if a player name was specified as a param.
final L2PcInstance plyr = L2World.getInstance().getPlayer(resParam);
if (plyr != null)
{
obj = plyr;
}
else
{
// Otherwise, check if the param was a radius.
try
{
final int radius = Integer.parseInt(resParam);
for (final L2PcInstance knownPlayer : activeChar.getKnownList().getKnownPlayersInRadius(radius))
{
doResurrect(knownPlayer);
}
activeChar.sendMessage("Resurrected all players within a " + radius + " unit radius.");
return;
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Enter a valid player name or radius.");
return;
}
}
}
if (obj == null)
{
obj = activeChar;
}
if (obj instanceof L2ControllableMobInstance)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
return;
}
doResurrect((L2Character) obj);
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") resurrected character " + obj.getObjectId());
}
}
private void handleNonPlayerRes(L2PcInstance activeChar)
{
handleNonPlayerRes(activeChar, "");
}
private void handleNonPlayerRes(L2PcInstance activeChar, String radiusStr)
{
final L2Object obj = activeChar.getTarget();
try
{
int radius = 0;
if (!radiusStr.isEmpty())
{
radius = Integer.parseInt(radiusStr);
for (final L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
{
if (!(knownChar instanceof L2PcInstance) && !(knownChar instanceof L2ControllableMobInstance))
{
doResurrect(knownChar);
}
}
activeChar.sendMessage("Resurrected all non-players within a " + radius + " unit radius.");
}
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Enter a valid radius.");
return;
}
if ((obj == null) || (obj instanceof L2PcInstance) || (obj instanceof L2ControllableMobInstance))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
return;
}
doResurrect((L2Character) obj);
}
private void doResurrect(L2Character targetChar)
{
if (!targetChar.isDead())
{
return;
}
// If the target is a player, then restore the XP lost on death.
if (targetChar instanceof L2PcInstance)
{
((L2PcInstance) targetChar).restoreExp(100.0);
}
else
{
DecayTaskManager.getInstance().cancelDecayTask(targetChar);
}
targetChar.doRevive();
}
}

View File

@@ -0,0 +1,100 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author TODO nothing.
*/
public class AdminRideWyvern implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_ride_wyvern",
"admin_ride_strider",
"admin_unride_wyvern",
"admin_unride_strider",
"admin_unride",
};
private static final int REQUIRED_LEVEL = Config.GM_RIDER;
private int PetRideId;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_ride"))
{
if (activeChar.isMounted() || (activeChar.getPet() != null))
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Already Have a Pet or Mounted.");
activeChar.sendPacket(sm);
return false;
}
if (command.startsWith("admin_ride_wyvern"))
{
PetRideId = 12621;
}
else if (command.startsWith("admin_ride_strider"))
{
PetRideId = 12526;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Command '" + command + "' not recognized");
activeChar.sendPacket(sm);
return false;
}
activeChar.mount(PetRideId, 0, false);
return false;
}
else if (command.startsWith("admin_unride"))
{
activeChar.dismount();
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,134 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.TradeController;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2TradeList;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.BuyList;
import com.l2jmobius.gameserver.network.serverpackets.SellList;
/**
* This class handles following admin commands: - gmshop = shows menu - buy id = shows shop with respective id - sell = sells items
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminShop implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminShop.class.getName());
private static String[] _adminCommands =
{
"admin_buy",
"admin_sell",
"admin_gmshop"
};
private static final int REQUIRED_LEVEL = Config.GM_CREATE_ITEM;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_buy"))
{
try
{
handleBuyRequest(activeChar, command.substring(10));
}
catch (final IndexOutOfBoundsException e)
{
activeChar.sendMessage("Please specify a buylist.");
}
}
else if (command.startsWith("admin_sell"))
{
activeChar.sendPacket(new SellList(activeChar));
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") opened GM Shop sell list");
}
activeChar.sendPacket(new ActionFailed());
}
else if (command.equals("admin_gmshop"))
{
AdminHelpPage.showHelpPage(activeChar, "gmshops.htm");
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleBuyRequest(L2PcInstance activeChar, String command)
{
int val = -1;
try
{
val = Integer.parseInt(command);
}
catch (final Exception e)
{
_log.warning("admin buylist failed:" + command);
}
final L2TradeList list = TradeController.getInstance().getBuyList(val);
if (list != null)
{
final BuyList bl = new BuyList(list, activeChar.getAdena());
activeChar.sendPacket(bl);
if (Config.DEBUG)
{
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") opened GM shop id " + val);
}
}
else
{
_log.warning("no buylist with id:" + val);
}
activeChar.sendPacket(new ActionFailed());
}
}

View File

@@ -0,0 +1,152 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.Shutdown;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - server_shutdown [sec] = shows menu or shuts down server in sec seconds
* @version $Revision: 1.5.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminShutdown implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminShutdown.class.getName());
private static String[] _adminCommands =
{
"admin_server_shutdown",
"admin_server_restart",
"admin_server_abort"
};
private static final int REQUIRED_LEVEL = Config.GM_RESTART;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_server_shutdown"))
{
try
{
final int val = Integer.parseInt(command.substring(22));
serverShutdown(activeChar, val, false);
}
catch (final StringIndexOutOfBoundsException e)
{
sendHtmlForm(activeChar);
}
}
else if (command.startsWith("admin_server_restart"))
{
try
{
final int val = Integer.parseInt(command.substring(21));
serverShutdown(activeChar, val, true);
}
catch (final StringIndexOutOfBoundsException e)
{
sendHtmlForm(activeChar);
}
}
else if (command.startsWith("admin_server_abort"))
{
serverAbort(activeChar);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void sendHtmlForm(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final int t = GameTimeController.getInstance().getGameTime();
final int h = t / 60;
final int m = t % 60;
final SimpleDateFormat format = new SimpleDateFormat("h:mm a");
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, h);
cal.set(Calendar.MINUTE, m);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Server Management Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td>Players Online: " + L2World.getInstance().getAllPlayersCount() + "</td></tr>");
replyMSG.append("<tr><td>Used Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) + " bytes</td></tr>");
replyMSG.append("<tr><td>Server Rates: " + Config.RATE_XP + "x, " + Config.RATE_SP + "x, " + Config.RATE_DROP_ADENA + "x, " + Config.RATE_DROP_ITEMS + "x, " + Config.RATE_BOSS_DROP_ITEMS + "x</td></tr>");
replyMSG.append("<tr><td>Game Time: " + format.format(cal.getTime()) + "</td></tr>");
replyMSG.append("</table><br>");
replyMSG.append("<table width=270>");
replyMSG.append("<tr><td>Enter in seconds the time till the server shutdowns bellow:</td></tr>");
replyMSG.append("<br>");
replyMSG.append("<tr><td><center>Seconds till: <edit var=\"shutdown_time\" width=60></center></td></tr>");
replyMSG.append("</table><br>");
replyMSG.append("<center><table><tr><td>");
replyMSG.append("<button value=\"Shutdown\" action=\"bypass -h admin_server_shutdown $shutdown_time\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Restart\" action=\"bypass -h admin_server_restart $shutdown_time\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td>");
replyMSG.append("<button value=\"Abort\" action=\"bypass -h admin_server_abort\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("</td></tr></table></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void serverShutdown(L2PcInstance activeChar, int seconds, boolean restart)
{
Shutdown.getInstance().startShutdown(activeChar, seconds, restart);
}
private void serverAbort(L2PcInstance activeChar)
{
Shutdown.getInstance().abort(activeChar);
}
}

View File

@@ -0,0 +1,425 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.ClanTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.AuctionManager;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.ClanHallManager;
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.ClanHall;
import com.l2jmobius.gameserver.model.zone.type.L2ClanHallZone;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import javolution.text.TextBuilder;
/**
* This class handles all siege commands: Todo: change the class name, and neaten it up
*/
public class AdminSiege implements IAdminCommandHandler
{
// private static Logger _log = Logger.getLogger(AdminSiege.class.getName());
private static String[] _adminCommands =
{
"admin_siege",
"admin_add_attacker",
"admin_add_defender",
"admin_add_guard",
"admin_list_siege_clans",
"admin_clear_siege_list",
"admin_move_defenders",
"admin_spawn_doors",
"admin_endsiege",
"admin_startsiege",
"admin_setcastle",
"admin_clanhall",
"admin_clanhallset",
"admin_clanhalldel",
"admin_clanhallopendoors",
"admin_clanhallclosedoors",
"admin_clanhallteleportself"
};
private static final int REQUIRED_LEVEL = Config.GM_NPC_EDIT;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if ((activeChar.getAccessLevel() < REQUIRED_LEVEL) || !activeChar.isGM())
{
return false;
}
}
final StringTokenizer st = new StringTokenizer(command, " ");
command = st.nextToken(); // Get actual command
// Get castle
Castle castle = null;
ClanHall clanhall = null;
if (command.startsWith("admin_clanhall"))
{
clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(st.nextToken()));
}
else if (st.hasMoreTokens())
{
castle = CastleManager.getInstance().getCastle(st.nextToken());
}
// Get castle
String val = "";
if (st.hasMoreTokens())
{
val = st.nextToken();
}
if (((castle == null) || (castle.getCastleId() < 0)) && (clanhall == null))
{
// No castle specified
showCastleSelectPage(activeChar);
}
else
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
if (command.equalsIgnoreCase("admin_add_attacker"))
{
if (player == null)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
}
else
{
if ((castle != null) && !SiegeManager.getInstance().checkIsRegistered(player.getClan(), castle.getCastleId()))
{
castle.getSiege().registerAttacker(player, true);
}
}
}
else if (command.equalsIgnoreCase("admin_add_defender"))
{
if (player == null)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
}
else
{
if ((castle != null) && !SiegeManager.getInstance().checkIsRegistered(player.getClan(), castle.getCastleId()))
{
castle.getSiege().registerDefender(player, true);
}
}
}
else if (command.equalsIgnoreCase("admin_add_guard"))
{
if ((castle != null) && (val != ""))
{
try
{
final int npcId = Integer.parseInt(val);
castle.getSiege().getSiegeGuardManager().addSiegeGuard(activeChar, npcId);
}
catch (final Exception e)
{
activeChar.sendMessage("Value entered for Npc Id wasn't an integer");
}
}
else
{
activeChar.sendMessage("Missing Npc Id");
}
}
else if ((castle != null) && command.equalsIgnoreCase("admin_clear_siege_list"))
{
castle.getSiege().clearSiegeClan();
}
else if ((castle != null) && command.equalsIgnoreCase("admin_endsiege"))
{
castle.getSiege().endSiege();
}
else if ((castle != null) && command.equalsIgnoreCase("admin_list_siege_clans"))
{
castle.getSiege().listRegisterClan(activeChar);
return true;
}
else if (command.equalsIgnoreCase("admin_move_defenders"))
{
activeChar.sendPacket(SystemMessage.sendString("Not implemented yet."));
}
else if (command.equalsIgnoreCase("admin_setcastle"))
{
if ((player == null) || (player.getClan() == null))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
}
else if ((castle != null) && (player.getClan().getHasCastle() == 0))
{
castle.setOwner(player.getClan());
}
}
else if (command.equalsIgnoreCase("admin_clanhallset"))
{
if ((player == null) || (player.getClan() == null))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
}
else
{
if (player.getClan().getHasHideout() == 0)
{
if ((clanhall != null) && (clanhall.getOwnerId() == 0))
{
clanhall.setOwner(player.getClan());
if (AuctionManager.getInstance().getAuction(player.getClan().getAuctionBiddedAt()) != null)
{
AuctionManager.getInstance().getAuction(player.getClan().getAuctionBiddedAt()).cancelBid(player.getClan().getClanId());
}
if (AuctionManager.getInstance().getAuction(clanhall.getId()) != null)
{
if (!AuctionManager.getInstance().getAuction(clanhall.getId()).getBidders().isEmpty())
{
AuctionManager.getInstance().getAuction(clanhall.getId()).removeBids();
}
AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
}
}
}
}
}
else if (command.equalsIgnoreCase("admin_clanhalldel"))
{
if ((clanhall != null) && (clanhall.getOwnerId() > 0))
{
clanhall.setOwner(null);
}
}
else if ((clanhall != null) && command.equalsIgnoreCase("admin_clanhallopendoors"))
{
clanhall.openCloseDoors(true);
}
else if ((clanhall != null) && command.equalsIgnoreCase("admin_clanhallclosedoors"))
{
clanhall.openCloseDoors(false);
}
else if (command.equalsIgnoreCase("admin_clanhallteleportself"))
{
if (clanhall != null)
{
final L2ClanHallZone zone = clanhall.getZone();
if (zone != null)
{
activeChar.teleToLocation(zone.getSpawnLoc(), true);
}
}
}
else if ((castle != null) && command.equalsIgnoreCase("admin_spawn_doors"))
{
castle.spawnDoor();
}
else if ((castle != null) && (clanhall != null) && command.equalsIgnoreCase("admin_startsiege"))
{
castle.getSiege().startSiege();
}
if (clanhall != null)
{
showClanHallPage(activeChar, clanhall);
}
else if (castle != null)
{
showSiegePage(activeChar, castle.getName());
}
}
return true;
}
public void showCastleSelectPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Siege Castle ClanHall Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<center>");
replyMSG.append("<br>Please select<br1>");
replyMSG.append("<table width=320><tr>");
replyMSG.append("<td>Castles:<br></td><td>ClanHalls:<br></td><td></td></tr><tr>");
replyMSG.append("<td>");
for (final Castle castle : CastleManager.getInstance().getCastles())
{
if (castle != null)
{
replyMSG.append("<a action=\"bypass -h admin_siege " + castle.getName() + "\">" + castle.getName() + "</a><br1>");
}
}
replyMSG.append("</td><td>");
int id = 0;
for (final ClanHall clanhall : ClanHallManager.getInstance().getClanHalls())
{
id++;
if (id > 15)
{
replyMSG.append("</td><td>");
id = 0;
}
if (clanhall != null)
{
replyMSG.append("<a action=\"bypass -h admin_clanhall " + clanhall.getId() + "\">" + clanhall.getName() + "</a><br1>");
}
}
replyMSG.append("</td></tr></table>");
replyMSG.append("</center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showSiegePage(L2PcInstance activeChar, String castleName)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Siege Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_siege\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<center>");
replyMSG.append("<br><br><br>Castle: " + castleName + "<br><br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Add Attacker\" action=\"bypass -h admin_add_attacker " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Add Defender\" action=\"bypass -h admin_add_defender " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("<tr><td><button value=\"List Clans\" action=\"bypass -h admin_list_siege_clans " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Clear List\" action=\"bypass -h admin_clear_siege_list " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Move Defenders\" action=\"bypass -h admin_move_defenders " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Spawn Doors\" action=\"bypass -h admin_spawn_doors " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Start Siege\" action=\"bypass -h admin_startsiege " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"End Siege\" action=\"bypass -h admin_endsiege " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Give Castle\" action=\"bypass -h admin_setcastle " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td>NpcId: <edit var=\"value\" width=40>");
replyMSG.append("<td><button value=\"Add Guard\" action=\"bypass -h admin_add_guard " + castleName + " $value\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("</center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Siege Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_siege\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<center>");
replyMSG.append("<br><br><br>ClanHall: " + clanhall.getName() + "<br>");
final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
if (owner == null)
{
replyMSG.append("ClanHall Owner: none<br><br>");
}
else
{
replyMSG.append("ClanHall Owner: " + owner.getName() + "<br><br>");
}
// replyMSG.append("<table>");
// replyMSG.append("<tr><td><button value=\" Owner\" action=\"bypass -h admin_clanhallset " + clanhall.getId() + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
// replyMSG.append("</table>");
replyMSG.append("<br>");
// replyMSG.append("<td><button value=\"Add Defender\" action=\"bypass -h admin_add_defender " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
// replyMSG.append("<tr><td><button value=\"List Clans\" action=\"bypass -h admin_list_siege_clans " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
// replyMSG.append("<td><button value=\"Clear List\" action=\"bypass -h admin_clear_siege_list " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
// replyMSG.append("<table>");
// replyMSG.append("<tr><td><button value=\"Move Defenders\" action=\"bypass -h admin_move_defenders " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
// replyMSG.append("<td><button value=\"Spawn Doors\" action=\"bypass -h admin_spawn_doors " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
// replyMSG.append("</table>");
replyMSG.append("<br>");
// replyMSG.append("<table>");
// replyMSG.append("<tr><td><button value=\"Start Siege\" action=\"bypass -h admin_startsiege " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
// replyMSG.append("<td><button value=\"End Siege\" action=\"bypass -h admin_endsiege " + castleName + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
// replyMSG.append("</table>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Open Doors\" action=\"bypass -h admin_clanhallopendoors " + clanhall.getId() + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Close Doors\" action=\"bypass -h admin_clanhallclosedoors " + clanhall.getId() + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Give ClanHall\" action=\"bypass -h admin_clanhallset " + clanhall.getId() + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Take ClanHall\" action=\"bypass -h admin_clanhalldel " + clanhall.getId() + "\" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table><tr>");
// replyMSG.append("<tr><td>NpcId: <edit var=\"value\" width=40>");
replyMSG.append("<td><button value=\"Teleport self\" action=\"bypass -h admin_clanhallteleportself " + clanhall.getId() + " \" width=80 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("</center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
}

View File

@@ -0,0 +1,594 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.datatables.SkillTreeTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2SkillLearn;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - show_skills - remove_skills - skill_list - skill_index - add_skill - remove_skill - get_skills - reset_skills - give_all_skills - remove_all_skills
* @version $Revision: 1.2.4.7 $ $Date: 2005/04/11 10:06:02 $
*/
public class AdminSkill implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminSkill.class.getName());
private static String[] _adminCommands =
{
"admin_show_skills",
"admin_remove_skills",
"admin_skill_list",
"admin_skill_index",
"admin_add_skill",
"admin_remove_skill",
"admin_get_skills",
"admin_reset_skills",
"admin_give_all_skills",
"admin_remove_all_skills"
};
private static final int REQUIRED_LEVEL = Config.GM_CHAR_EDIT;
private static final int REQUIRED_LEVEL2 = Config.GM_CHAR_EDIT_OTHER;
private static L2Skill[] adminSkills;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (command.equals("admin_show_skills"))
{
showSkillsPage(activeChar);
}
else if (command.startsWith("admin_remove_skills"))
{
try
{
final String val = command.substring(20);
removeSkillsPage(activeChar, Integer.parseInt(val));
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_skill_list"))
{
AdminHelpPage.showHelpPage(activeChar, "skills.htm");
}
else if (command.startsWith("admin_skill_index"))
{
try
{
final String val = command.substring(18);
AdminHelpPage.showHelpPage(activeChar, "skills/" + val + ".htm");
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_add_skill"))
{
try
{
final String val = command.substring(15);
if ((activeChar == activeChar.getTarget()) || (activeChar.getAccessLevel() >= REQUIRED_LEVEL2))
{
adminAddSkill(activeChar, val);
}
}
catch (final StringIndexOutOfBoundsException e)
{ // Case of empty character name
final SystemMessage sm = new SystemMessage(614);
sm.addString("Error while adding skill.");
activeChar.sendPacket(sm);
}
}
else if (command.startsWith("admin_remove_skill"))
{
try
{
final String id = command.substring(19);
final int idval = Integer.parseInt(id);
if ((activeChar == activeChar.getTarget()) || (activeChar.getAccessLevel() >= REQUIRED_LEVEL2))
{
adminRemoveSkill(activeChar, idval);
}
}
catch (final StringIndexOutOfBoundsException e)
{ // Case of empty character name
final SystemMessage sm = new SystemMessage(614);
sm.addString("Error while removing skill.");
activeChar.sendPacket(sm);
}
}
else if (command.equals("admin_get_skills"))
{
adminGetSkills(activeChar);
}
else if (command.equals("admin_reset_skills"))
{
if ((activeChar == activeChar.getTarget()) || (activeChar.getAccessLevel() >= REQUIRED_LEVEL2))
{
adminResetSkills(activeChar);
}
}
else if (command.equals("admin_give_all_skills"))
{
if ((activeChar == activeChar.getTarget()) || (activeChar.getAccessLevel() >= REQUIRED_LEVEL2))
{
adminGiveAllSkills(activeChar);
}
}
else if (command.equals("admin_remove_all_skills"))
{
if (activeChar.getTarget() instanceof L2PcInstance)
{
final L2PcInstance player = (L2PcInstance) activeChar.getTarget();
for (final L2Skill skill : player.getAllSkills())
{
player.removeSkill(skill);
}
activeChar.sendMessage("You removed all skills from " + player.getName());
player.sendMessage("Admin removed all skills from you.");
}
}
return true;
}
/**
* This function will give all the skills that the gm target can have at its level to the traget
* @param activeChar : the gm char
*/
private void adminGiveAllSkills(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
if (target == null)
{
return;
}
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
int skillCounter = 0;
final L2SkillLearn[] skills = SkillTreeTable.getInstance().getMaxAvailableSkills(player, player.getClassId());
for (final L2SkillLearn s : skills)
{
final L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
if ((sk == null) || !sk.getCanLearn(player.getClassId()))
{
continue;
}
if (player.getSkillLevel(sk.getId()) == -1)
{
skillCounter++;
}
player.addSkill(sk, true);
}
// Notify player and admin
if (skillCounter > 0)
{
player.sendMessage("A GM gave you " + skillCounter + " skills.");
activeChar.sendMessage("You gave " + skillCounter + " skills to " + player.getName());
}
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
// ok
private void removeSkillsPage(L2PcInstance activeChar, int page)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final L2Skill[] skills = player.getAllSkills();
final int MaxSkillsPerPage = 10;
int MaxPages = skills.length / MaxSkillsPerPage;
if (skills.length > (MaxSkillsPerPage * MaxPages))
{
MaxPages++;
}
if (page > MaxPages)
{
page = MaxPages;
}
final int SkillsStart = MaxSkillsPerPage * page;
int SkillsEnd = skills.length;
if ((SkillsEnd - SkillsStart) > MaxSkillsPerPage)
{
SkillsEnd = SkillsStart + MaxSkillsPerPage;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Character Selection Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_show_skills\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<center>Editing <font color=\"LEVEL\">" + player.getName() + "</font></center>");
replyMSG.append("<br><table width=270><tr><td>Lv: " + player.getLevel() + " " + player.getTemplate().className + "</td></tr></table>");
replyMSG.append("<br><table width=270><tr><td>Note: Dont forget that modifying players skills can</td></tr>");
replyMSG.append("<tr><td>ruin the game...</td></tr></table>");
replyMSG.append("<br><center>Click on the skill you wish to remove:</center>");
replyMSG.append("<br>");
String pages = "<center><table width=270><tr>";
for (int x = 0; x < MaxPages; x++)
{
final int pagenr = x + 1;
pages += "<td><a action=\"bypass -h admin_remove_skills " + x + "\">Page " + pagenr + "</a></td>";
}
pages += "</tr></table></center>";
replyMSG.append(pages);
replyMSG.append("<br><table width=270>");
replyMSG.append("<tr><td width=80>Name:</td><td width=60>Level:</td><td width=40>Id:</td></tr>");
for (int i = SkillsStart; i < SkillsEnd; i++)
{
replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_remove_skill " + skills[i].getId() + "\">" + skills[i].getName() + "</a></td><td width=60>" + skills[i].getLevel() + "</td><td width=40>" + skills[i].getId() + "</td></tr>");
}
replyMSG.append("</table>");
replyMSG.append("<br><center><table>");
replyMSG.append("Remove custom skill:");
replyMSG.append("<tr><td>Id: </td>");
replyMSG.append("<td><edit var=\"id_to_remove\" width=110></td></tr>");
replyMSG.append("</table></center>");
replyMSG.append("<center><button value=\"Remove skill\" action=\"bypass -h admin_remove_skill $id_to_remove\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center>");
replyMSG.append("<br><center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
// ok
private void showSkillsPage(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td width=180><center>Character Selection Menu</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<center>Editing <font color=\"LEVEL\">" + player.getName() + "</font></center>");
replyMSG.append("<br><table width=270><tr><td>Lv: " + player.getLevel() + " " + player.getTemplate().className + "</td></tr></table>");
replyMSG.append("<br><table width=270><tr><td>Note: Dont forget that modifying players skills can</td></tr>");
replyMSG.append("<tr><td>ruin the game...</td></tr></table>");
replyMSG.append("<br><center><table>");
replyMSG.append("<tr><td><button value=\"Add skills\" action=\"bypass -h admin_skill_list\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Get skills\" action=\"bypass -h admin_get_skills\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("<tr><td><button value=\"Delete skills\" action=\"bypass -h admin_remove_skills 0\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Reset skills\" action=\"bypass -h admin_reset_skills\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("<tr><td><button value=\"Give All Skills\" action=\"bypass -h admin_give_all_skills\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void adminGetSkills(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
if (player.getName().equals(activeChar.getName()))
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("There is no point in doing it on your character...");
player.sendPacket(sm);
}
else
{
final L2Skill[] skills = player.getAllSkills();
adminSkills = activeChar.getAllSkills();
for (final L2Skill adminSkill : adminSkills)
{
activeChar.removeSkill(adminSkill);
}
for (final L2Skill skill : skills)
{
activeChar.addSkill(skill, true);
}
final SystemMessage smA = new SystemMessage(614);
smA.addString("You now have all the skills of " + player.getName() + ".");
activeChar.sendPacket(smA);
}
showSkillsPage(activeChar);
}
private void adminResetSkills(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
if (adminSkills == null)
{
final SystemMessage smA = new SystemMessage(614);
smA.addString("You must first get the skills of someone to do this.");
activeChar.sendPacket(smA);
}
else
{
final L2Skill[] skills = player.getAllSkills();
for (final L2Skill skill : skills)
{
player.removeSkill(skill);
}
for (int i = 0; i < activeChar.getAllSkills().length; i++)
{
player.addSkill(activeChar.getAllSkills()[i], true);
}
for (final L2Skill skill : skills)
{
activeChar.removeSkill(skill);
}
for (final L2Skill adminSkill : adminSkills)
{
activeChar.addSkill(adminSkill, true);
}
final SystemMessage sm = new SystemMessage(614);
sm.addString("[GM]" + activeChar.getName() + " has updated your skills.");
player.sendPacket(sm);
final SystemMessage smA = new SystemMessage(614);
smA.addString("You now have all your skills back.");
activeChar.sendPacket(smA);
adminSkills = null;
}
showSkillsPage(activeChar);
}
private void adminAddSkill(L2PcInstance activeChar, String val)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final StringTokenizer st = new StringTokenizer(val);
if (st.countTokens() != 2)
{
showSkillsPage(activeChar);
}
else
{
final String id = st.nextToken();
final String level = st.nextToken();
final int idval = Integer.parseInt(id);
final int levelval = Integer.parseInt(level);
final L2Skill skill = SkillTable.getInstance().getInfo(idval, levelval);
if (skill != null)
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Admin gave you the skill " + skill.getName() + ".");
player.sendPacket(sm);
player.addSkill(skill, true);
// Admin information
final SystemMessage smA = new SystemMessage(614);
smA.addString("You gave the skill " + skill.getName() + " to " + player.getName() + ".");
activeChar.sendPacket(smA);
if (Config.DEBUG)
{
_log.fine("[GM]" + activeChar.getName() + "gave the skill " + skill.getName() + " to " + player.getName() + ".");
}
}
else
{
final SystemMessage smA = new SystemMessage(614);
smA.addString("Error: there is no such skill.");
}
showSkillsPage(activeChar); // Back to start
}
}
private void adminRemoveSkill(L2PcInstance activeChar, int idval)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Incorrect target.");
activeChar.sendPacket(sm);
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(idval, player.getSkillLevel(idval));
if (skill != null)
{
final SystemMessage sm = new SystemMessage(614);
sm.addString("Admin removed the skill " + skill.getName() + ".");
player.sendPacket(sm);
player.removeSkill(skill);
// Admin information
final SystemMessage smA = new SystemMessage(614);
smA.addString("You removed the skill " + skill.getName() + " from " + player.getName() + ".");
activeChar.sendPacket(smA);
if (Config.DEBUG)
{
_log.fine("[GM]" + activeChar.getName() + "removed the skill " + skill.getName() + " from " + player.getName() + ".");
}
}
else
{
final SystemMessage smA = new SystemMessage(614);
smA.addString("Error: there is no such skill.");
}
removeSkillsPage(activeChar, 0); // Back to start
}
public void showSkill(L2PcInstance activeChar, String val)
{
final int skillid = Integer.parseInt(val);
final L2Skill skill = SkillTable.getInstance().getInfo(skillid, 1);
if (skill != null)
{
if (skill.getTargetType() == L2Skill.SkillTargetType.TARGET_SELF)
{
activeChar.setTarget(activeChar);
final MagicSkillUse msk = new MagicSkillUse(activeChar, skillid, 1, skill.getHitTime(), skill.getReuseDelay());
activeChar.broadcastPacket(msk);
if (Config.DEBUG)
{
_log.fine("showing self skill, id: " + skill.getId() + " named: " + skill.getName());
}
}
else if (skill.getTargetType() == L2Skill.SkillTargetType.TARGET_ONE)
{
if (Config.DEBUG)
{
_log.fine("showing ATTACK skill, id: " + skill.getId() + " named: " + skill.getName());
}
}
}
else
{
if (Config.DEBUG)
{
_log.fine("no such skill id: " + skillid);
}
final ActionFailed af = new ActionFailed();
activeChar.broadcastPacket(af);
}
}
}

View File

@@ -0,0 +1,374 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.GmListTable;
import com.l2jmobius.gameserver.datatables.NpcTable;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.datatables.TeleportLocationTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2NpcTemplate;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
* @version $Revision: 1.2.2.5.2.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminSpawn implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_show_spawns",
"admin_spawn",
"admin_spawn_monster",
"admin_spawn_index",
"admin_unspawnall",
"admin_respawnall",
"admin_spawn_reload",
"admin_npc_index",
"admin_show_npcs",
"admin_teleport_reload",
"admin_spawnnight",
"admin_spawnday"
};
public static Logger _log = Logger.getLogger(AdminSpawn.class.getName());
private static final int REQUIRED_LEVEL = Config.GM_NPC_EDIT;
private static final int REQUIRED_LEVEL2 = Config.GM_TELEPORT_OTHER;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.equals("admin_show_spawns"))
{
AdminHelpPage.showHelpPage(activeChar, "spawns.htm");
}
else if (command.startsWith("admin_spawn_index"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
try
{
st.nextToken();
final int level = Integer.parseInt(st.nextToken());
int from = 0;
try
{
from = Integer.parseInt(st.nextToken());
}
catch (final NoSuchElementException nsee)
{
}
showMonsters(activeChar, level, from);
}
catch (final StringIndexOutOfBoundsException e)
{
AdminHelpPage.showHelpPage(activeChar, "spawns.htm");
}
catch (final NumberFormatException e)
{
AdminHelpPage.showHelpPage(activeChar, "spawns.htm");
}
}
else if (command.equals("admin_show_npcs"))
{
AdminHelpPage.showHelpPage(activeChar, "npcs.htm");
}
else if (command.startsWith("admin_npc_index"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
try
{
st.nextToken();
final String letter = st.nextToken();
int from = 0;
try
{
from = Integer.parseInt(st.nextToken());
}
catch (final NoSuchElementException nsee)
{
}
showNpcs(activeChar, letter, from);
}
catch (final StringIndexOutOfBoundsException e)
{
AdminHelpPage.showHelpPage(activeChar, "npcs.htm");
}
catch (final NumberFormatException e)
{
AdminHelpPage.showHelpPage(activeChar, "npcs.htm");
}
}
else if (command.startsWith("admin_spawn ") || command.startsWith("admin_spawn_monster"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
try
{
st.nextToken();
final String id = st.nextToken();
int respawnTime = 0;
// FIXME: 0 time should mean never respawn.
// At the moment it will just be set to d elsewhere.
int mobCount = 1;
if (st.hasMoreTokens())
{
mobCount = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
respawnTime = Integer.parseInt(st.nextToken());
}
spawnMonster(activeChar, id, respawnTime, mobCount);
}
catch (final Exception e)
{
// Case of wrong monster data
}
}
else if (command.startsWith("admin_unspawnall"))
{
for (final L2PcInstance player : L2World.getInstance().getAllPlayers())
{
player.sendPacket(new SystemMessage(SystemMessage.NPC_SERVER_NOT_OPERATING));
}
RaidBossSpawnManager.getInstance().cleanUp();
DayNightSpawnManager.getInstance().cleanUp();
L2World.getInstance().deleteVisibleNpcSpawns();
GmListTable.broadcastMessageToGMs("NPC Unspawn completed!");
}
else if (command.startsWith("admin_spawnday"))
{
DayNightSpawnManager.getInstance().spawnDayCreatures();
DayNightSpawnManager.getInstance().specialNightBoss(0);
}
else if (command.startsWith("admin_spawnnight"))
{
DayNightSpawnManager.getInstance().spawnNightCreatures();
DayNightSpawnManager.getInstance().specialNightBoss(1);
}
else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload"))
{
// make shure all spawns are deleted
RaidBossSpawnManager.getInstance().cleanUp();
DayNightSpawnManager.getInstance().cleanUp();
L2World.getInstance().deleteVisibleNpcSpawns();
// now respawn all
NpcTable.getInstance().reloadAllNpc();
SpawnTable.getInstance().reloadAll();
RaidBossSpawnManager.getInstance().reloadBosses();
DayNightSpawnManager.getInstance().notifyChangeMode();
QuestManager.getInstance().reloadAllQuests();
GmListTable.broadcastMessageToGMs("NPC Respawn completed!");
}
else if (command.startsWith("admin_teleport_reload"))
{
TeleportLocationTable.getInstance().reloadAll();
GmListTable.broadcastMessageToGMs("Teleport List Table reloaded.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void spawnMonster(L2PcInstance activeChar, String monsterId, int respawnTime, int mobCount)
{
L2Object target = activeChar.getTarget();
if (target == null)
{
target = activeChar;
}
if ((target != activeChar) && (activeChar.getAccessLevel() < REQUIRED_LEVEL2))
{
return;
}
final Pattern pattern = Pattern.compile("[0-9]*");
final Matcher regexp = pattern.matcher(monsterId);
L2NpcTemplate template1;
if (regexp.matches())
{
// First parameter was an ID number
final int monsterTemplate = Integer.parseInt(monsterId);
template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
}
else
{
// First parameter wasn't just numbers so go by name not ID
monsterId = monsterId.replace('_', ' ');
template1 = NpcTable.getInstance().getTemplateByName(monsterId);
}
try
{
final L2Spawn spawn = new L2Spawn(template1);
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
{
spawn.setCustom(true);
}
spawn.setLocx(target.getX());
spawn.setLocy(target.getY());
spawn.setLocz(target.getZ());
spawn.setAmount(mobCount);
spawn.setHeading(activeChar.getHeading());
spawn.setRespawnDelay(respawnTime);
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getNpcid()))
{
activeChar.sendMessage("You cannot spawn another instance of " + template1.name + ".");
}
else
{
if (RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getNpcid()) != null)
{
spawn.setRespawnMinDelay(43200);
spawn.setRespawnMaxDelay(129600);
RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template1.baseHpMax, template1.baseMpMax, true);
}
else
{
SpawnTable.getInstance().addNewSpawn(spawn, true);
spawn.init();
}
activeChar.sendMessage("Created " + template1.name + " on " + target.getObjectId() + ".");
}
}
catch (final Exception e)
{
activeChar.sendMessage("Target is not ingame.");
}
}
private void showMonsters(L2PcInstance activeChar, int level, int from)
{
final TextBuilder tb = new TextBuilder();
final L2NpcTemplate[] mobs = NpcTable.getInstance().getAllMonstersOfLevel(level);
// Start
tb.append("<html><title>Spawn Monster:</title><body><p> Level " + level + ":<br>Total Npc's : " + mobs.length + "<br>");
String end1 = "<br><center><button value=\"Next\" action=\"bypass -h admin_spawn_index " + level + " $from$\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>";
final String end2 = "<br><center><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>";
// Loop
boolean ended = true;
for (int i = from; i < mobs.length; i++)
{
final String txt = "<a action=\"bypass -h admin_spawn_monster " + mobs[i].npcId + "\">" + mobs[i].name + "</a><br1>";
if ((tb.length() + txt.length() + end2.length()) > 8192)
{
end1 = end1.replace("$from$", "" + i);
ended = false;
break;
}
tb.append(txt);
}
// End
if (ended)
{
tb.append(end2);
}
else
{
tb.append(end1);
}
activeChar.sendPacket(new NpcHtmlMessage(5, tb.toString()));
}
private void showNpcs(L2PcInstance activeChar, String starting, int from)
{
final TextBuilder tb = new TextBuilder();
final L2NpcTemplate[] mobs = NpcTable.getInstance().getAllNpcStartingWith(starting);
// Start
tb.append("<html><title>Spawn NPC:</title><body><p> There are " + mobs.length + " NPCs whose name starts with " + starting + ":<br>");
String end1 = "<br><center><button value=\"Next\" action=\"bypass -h admin_npc_index " + starting + " $from$\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>";
final String end2 = "<br><center><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>";
// Loop
boolean ended = true;
for (int i = from; i < mobs.length; i++)
{
final String txt = "<a action=\"bypass -h admin_spawn_monster " + mobs[i].npcId + "\">" + mobs[i].name + "</a><br1>";
if ((tb.length() + txt.length() + end2.length()) > 8192)
{
end1 = end1.replace("$from$", "" + i);
ended = false;
break;
}
tb.append(txt);
}
// End
if (ended)
{
tb.append(end2);
}
else
{
tb.append(end1);
}
activeChar.sendPacket(new NpcHtmlMessage(5, tb.toString()));
}
}

View File

@@ -0,0 +1,85 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands: - target name = sets player with respective name as target
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:05:56 $
*/
public class AdminTarget implements IAdminCommandHandler
{
private static String[] _adminCommands =
{
"admin_target"
};
private static final int REQUIRED_LEVEL = Config.GM_MIN;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_target"))
{
handleTarget(command, activeChar);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void handleTarget(String command, L2PcInstance activeChar)
{
try
{
final String targetName = command.substring(13);
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
if (player != null)
{
player.onAction(activeChar);
}
else
{
activeChar.sendMessage("Player " + targetName + " not found.");
}
}
catch (final IndexOutOfBoundsException e)
{
activeChar.sendMessage("Please specify a correct name.");
}
}
}

View File

@@ -0,0 +1,700 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.datatables.NpcTable;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.GMAudit;
import com.l2jmobius.gameserver.model.L2CharPosition;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2NpcTemplate;
import javolution.text.TextBuilder;
/**
* This class handles following admin commands: - show_moves - show_teleport - teleport_to_character - move_to - teleport_character
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminTeleport implements IAdminCommandHandler
{
private static final Logger _log = Logger.getLogger(AdminTeleport.class.getName());
private static String[] _adminCommands =
{
"admin_show_moves",
"admin_show_moves_other",
"admin_show_teleport",
"admin_teleport_to_character",
"admin_teleportto",
"admin_move_to",
"admin_teleport_character",
"admin_recall",
"admin_walk",
"admin_explore",
"teleportto",
"recall",
"admin_recall_npc",
"admin_gonorth",
"admin_gosouth",
"admin_goeast",
"admin_gowest",
"admin_goup",
"admin_godown",
"admin_tele",
"admin_teleto",
"admin_failed"
};
private static final int REQUIRED_LEVEL = Config.GM_TELEPORT;
private static final int REQUIRED_LEVEL2 = Config.GM_TELEPORT_OTHER;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
final String target = (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target");
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
if (command.equals("admin_teleto"))
{
activeChar.setTeleMode(1);
}
if (command.equals("admin_teleto r"))
{
activeChar.setTeleMode(2);
}
if (command.equals("admin_teleto end"))
{
activeChar.setTeleMode(0);
}
if (command.equals("admin_show_moves"))
{
AdminHelpPage.showHelpPage(activeChar, "teleports.htm");
}
if (command.equals("admin_show_moves_other"))
{
AdminHelpPage.showHelpPage(activeChar, "tele/other.html");
}
else if (command.equals("admin_show_teleport"))
{
showTeleportCharWindow(activeChar);
}
else if (command.equals("admin_recall_npc"))
{
recallNPC(activeChar);
}
else if (command.equals("admin_teleport_to_character"))
{
teleportToCharacter(activeChar, activeChar.getTarget());
}
else if (command.equals("admin_explore") && Config.ACTIVATE_POSITION_RECORDER)
{
activeChar._exploring = !activeChar._exploring;
activeChar.explore();
}
else if (command.startsWith("admin_walk"))
{
try
{
final String val = command.substring(11);
final StringTokenizer st = new StringTokenizer(val);
final String x1 = st.nextToken();
final int x = Integer.parseInt(x1);
final String y1 = st.nextToken();
final int y = Integer.parseInt(y1);
final String z1 = st.nextToken();
final int z = Integer.parseInt(z1);
final L2CharPosition pos = new L2CharPosition(x, y, z, 0);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, pos);
}
catch (final Exception e)
{
if (Config.DEBUG)
{
_log.info("admin_walk: " + e);
}
}
}
else if (command.startsWith("admin_move_to"))
{
try
{
final String val = command.substring(14);
teleportTo(activeChar, val);
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty co-ordinates
activeChar.sendMessage("Wrong or no Co-ordinates given.");
}
}
else if (command.startsWith("admin_teleport_character"))
{
try
{
final String val = command.substring(25);
if (activeChar.getAccessLevel() >= REQUIRED_LEVEL2)
{
teleportCharacter(activeChar, val);
}
}
catch (final StringIndexOutOfBoundsException e)
{
// Case of empty co-ordinates
activeChar.sendMessage("Wrong or no Co-ordinates given.");
showTeleportCharWindow(activeChar); // back to character teleport
}
}
else if (command.startsWith("admin_teleportto "))
{
try
{
final String targetName = command.substring(17);
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
teleportToCharacter(activeChar, player);
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_recall "))
{
try
{
if (activeChar.getAccessLevel() < REQUIRED_LEVEL2)
{
return false;
}
final String[] param = command.split(" ");
if (param.length != 2)
{
activeChar.sendMessage("Usage: //recall <playername>");
return false;
}
final String targetName = param[1];
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
if (player != null)
{
teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ(), activeChar);
}
else
{
changeCharacterPosition(activeChar, targetName);
}
}
catch (final StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_failed"))
{
final SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
sm.addString("Trying ActionFailed...");
activeChar.sendPacket(sm);
activeChar.sendPacket(new ActionFailed());
}
else if (command.equals("admin_tele"))
{
showTeleportWindow(activeChar);
}
else if (command.equals("admin_goup"))
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ() + 150;
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_goup"))
{
try
{
final String val = command.substring(11);
final int intVal = Integer.parseInt(val);
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ() + intVal;
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
catch (final NumberFormatException nfe)
{
}
}
else if (command.equals("admin_godown"))
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y, z - 150, false);
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_godown"))
{
try
{
final String val = command.substring(13);
final int intVal = Integer.parseInt(val);
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ() - intVal;
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
catch (final NumberFormatException nfe)
{
}
}
else if (command.equals("admin_goeast"))
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
activeChar.teleToLocation(x + 150, y, z, false);
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_goeast"))
{
try
{
final String val = command.substring(13);
final int intVal = Integer.parseInt(val);
final int x = activeChar.getX() + intVal;
final int y = activeChar.getY();
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
catch (final NumberFormatException nfe)
{
}
}
else if (command.equals("admin_gowest"))
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
activeChar.teleToLocation(x - 150, y, z, false);
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_gowest"))
{
try
{
final String val = command.substring(13);
final int intVal = Integer.parseInt(val);
final int x = activeChar.getX() - intVal;
final int y = activeChar.getY();
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
catch (final NumberFormatException nfe)
{
}
}
else if (command.equals("admin_gosouth"))
{
final int x = activeChar.getX();
final int y = activeChar.getY() + 150;
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_gosouth"))
{
try
{
final String val = command.substring(14);
final int intVal = Integer.parseInt(val);
final int x = activeChar.getX();
final int y = activeChar.getY() + intVal;
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
catch (final NumberFormatException nfe)
{
}
}
else if (command.equals("admin_gonorth"))
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y - 150, z, false);
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_gonorth"))
{
try
{
final String val = command.substring(14);
final int intVal = Integer.parseInt(val);
final int x = activeChar.getX();
final int y = activeChar.getY() - intVal;
final int z = activeChar.getZ();
activeChar.teleToLocation(x, y, z, false);
showTeleportWindow(activeChar);
}
catch (final StringIndexOutOfBoundsException e)
{
}
catch (final NumberFormatException nfe)
{
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
private void teleportTo(L2PcInstance activeChar, String Cords)
{
try
{
final StringTokenizer st = new StringTokenizer(Cords);
final String x1 = st.nextToken();
final int x = Integer.parseInt(x1);
final String y1 = st.nextToken();
final int y = Integer.parseInt(y1);
final String z1 = st.nextToken();
final int z = Integer.parseInt(z1);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
activeChar.teleToLocation(x, y, z, false);
final SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
sm.addString("You have been teleported to " + Cords);
activeChar.sendPacket(sm);
}
catch (final NoSuchElementException nsee)
{
activeChar.sendMessage("Wrong or no Co-ordinates given.");
}
}
private void showTeleportWindow(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><title>Teleport Menu</title>");
replyMSG.append("<body>");
replyMSG.append("<br>");
replyMSG.append("<center><table>");
replyMSG.append("<tr><td><button value=\" \" action=\"bypass -h admin_tele\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"North\" action=\"bypass -h admin_gonorth\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Up\" action=\"bypass -h admin_goup\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("<tr><td><button value=\"West\" action=\"bypass -h admin_gowest\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\" \" action=\"bypass -h admin_tele\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"East\" action=\"bypass -h admin_goeast\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("<tr><td><button value=\" \" action=\"bypass -h admin_tele\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"South\" action=\"bypass -h admin_gosouth\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Down\" action=\"bypass -h admin_godown\" width=70 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
replyMSG.append("</table></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void showTeleportCharWindow(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("Incorrect target.");
return;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final TextBuilder replyMSG = new TextBuilder("<html><title>Teleport Character</title>");
replyMSG.append("<body>");
replyMSG.append("The character you will teleport is " + player.getName() + ".");
replyMSG.append("<br>");
replyMSG.append("Co-ordinate x");
replyMSG.append("<edit var=\"char_cord_x\" width=110>");
replyMSG.append("Co-ordinate y");
replyMSG.append("<edit var=\"char_cord_y\" width=110>");
replyMSG.append("Co-ordinate z");
replyMSG.append("<edit var=\"char_cord_z\" width=110>");
replyMSG.append("<button value=\"Teleport\" action=\"bypass -h admin_teleport_character $char_cord_x $char_cord_y $char_cord_z\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("<button value=\"Teleport near you\" action=\"bypass -h admin_teleport_character " + activeChar.getX() + " " + activeChar.getY() + " " + activeChar.getZ() + "\" width=115 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
replyMSG.append("<center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
private void teleportCharacter(L2PcInstance activeChar, String Cords)
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("Incorrect target.");
return;
}
if (player.getObjectId() == activeChar.getObjectId())
{
player.sendMessage("You cannot teleport your character.");
}
else
{
try
{
final StringTokenizer st = new StringTokenizer(Cords);
final String x1 = st.nextToken();
final int x = Integer.parseInt(x1);
final String y1 = st.nextToken();
final int y = Integer.parseInt(y1);
final String z1 = st.nextToken();
final int z = Integer.parseInt(z1);
teleportCharacter(player, x, y, z, null);
}
catch (final NoSuchElementException nsee)
{
}
}
}
/**
* @param player
* @param x
* @param y
* @param z
* @param activeChar
*/
private void teleportCharacter(L2PcInstance player, int x, int y, int z, L2PcInstance activeChar)
{
if (player != null)
{
// Check for jail
if (player.isInJail())
{
activeChar.sendMessage("Sorry, player " + player.getName() + " is in Jail.");
return;
}
// Information
if (activeChar != null)
{
activeChar.sendMessage("You have recalled " + player.getName());
}
player.sendMessage("Admin is teleporting you.");
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
player.teleToLocation(x, y, z, true);
}
}
private void changeCharacterPosition(L2PcInstance activeChar, String name)
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"))
{
statement.setInt(1, x);
statement.setInt(2, y);
statement.setInt(3, z);
statement.setString(4, name);
statement.execute();
final int count = statement.getUpdateCount();
if (count == 0)
{
activeChar.sendMessage("Character not found or position is not altered.");
}
else
{
activeChar.sendMessage("Player's [" + name + "] position is now set to (" + x + "," + y + "," + z + ").");
}
}
catch (final SQLException se)
{
activeChar.sendMessage("SQLException while changing offline character's position");
}
}
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
{
L2PcInstance player = null;
if ((target != null) && (target instanceof L2PcInstance))
{
player = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("Incorrect target.");
return;
}
if (player.getObjectId() == activeChar.getObjectId())
{
activeChar.sendMessage("You cannot self teleport.");
}
else
{
final int x = player.getX();
final int y = player.getY();
final int z = player.getZ();
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
activeChar.teleToLocation(x, y, z, true);
activeChar.sendMessage("You have teleported to character " + player.getName() + ".");
}
}
private void recallNPC(L2PcInstance activeChar)
{
final L2Object obj = activeChar.getTarget();
if ((obj != null) && (obj instanceof L2NpcInstance))
{
final L2NpcInstance target = (L2NpcInstance) obj;
final int monsterTemplate = target.getTemplate().npcId;
final L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
if (template1 == null)
{
activeChar.sendMessage("Incorrect monster template.");
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' template.");
return;
}
L2Spawn spawn = target.getSpawn();
if (spawn == null)
{
activeChar.sendMessage("Incorrect monster spawn.");
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
return;
}
final int respawnTime = spawn.getRespawnDelay();
target.deleteMe();
spawn.stopRespawn();
SpawnTable.getInstance().deleteSpawn(spawn, true);
try
{
// L2MonsterInstance mob = new L2MonsterInstance(monsterTemplate, template1);
spawn = new L2Spawn(template1);
spawn.setLocx(activeChar.getX());
spawn.setLocy(activeChar.getY());
spawn.setLocz(activeChar.getZ());
spawn.setAmount(1);
spawn.setHeading(activeChar.getHeading());
spawn.setRespawnDelay(respawnTime);
SpawnTable.getInstance().addNewSpawn(spawn, true);
spawn.init();
final SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
sm.addString("Created " + template1.name + " on " + target.getObjectId() + ".");
activeChar.sendPacket(sm);
if (Config.DEBUG)
{
_log.fine("Spawn at X=" + spawn.getLocx() + " Y=" + spawn.getLocy() + " Z=" + spawn.getLocz());
_log.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") moved NPC " + target.getObjectId());
}
}
catch (final Exception e)
{
activeChar.sendMessage("Target is not in game.");
}
}
else
{
activeChar.sendMessage("Incorrect target.");
}
}
}

View File

@@ -0,0 +1,138 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.Universe;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
/**
* This class ...
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
*/
public class AdminTest implements IAdminCommandHandler
{
private static final int REQUIRED_LEVEL = Config.GM_TEST;
public static final String[] ADMIN_TEST_COMMANDS =
{
"admin_test",
"admin_stats",
"admin_skill_test",
"admin_st",
"admin_known"
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (activeChar.getAccessLevel() < REQUIRED_LEVEL)
{
return false;
}
}
if (command.equals("admin_stats"))
{
for (final String line : ThreadPoolManager.getInstance().getStats())
{
activeChar.sendMessage(line);
}
}
else if (command.startsWith("admin_skill_test") || command.startsWith("admin_st"))
{
try
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
final int id = Integer.parseInt(st.nextToken());
adminTestSkill(activeChar, id);
}
catch (final NumberFormatException e)
{
activeChar.sendMessage("Command format is //skill_test <ID>");
}
catch (final NoSuchElementException nsee)
{
activeChar.sendMessage("Command format is //skill_test <ID>");
}
}
else if (command.startsWith("admin_test uni flush"))
{
Universe.getInstance().flush();
activeChar.sendMessage("Universe Map Saved.");
}
else if (command.startsWith("admin_test uni"))
{
activeChar.sendMessage("Universe Map Size is: " + Universe.getInstance().size());
}
else if (command.equals("admin_known on"))
{
Config.CHECK_KNOWN = true;
}
else if (command.equals("admin_known off"))
{
Config.CHECK_KNOWN = false;
}
return true;
}
/**
* @param activeChar
* @param id
*/
private void adminTestSkill(L2PcInstance activeChar, int id)
{
L2Character player;
final L2Object target = activeChar.getTarget();
if ((target == null) || !(target instanceof L2Character))
{
player = activeChar;
}
else
{
player = (L2Character) target;
}
player.broadcastPacket(new MagicSkillUse(activeChar, player, id, 1, 1, 1));
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
*/
@Override
public String[] getAdminCommandList()
{
return ADMIN_TEST_COMMANDS;
}
}

View File

@@ -0,0 +1,82 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands:
* <ul>
* <li>admin_unblockip</li>
* </ul>
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminUnblockIp implements IAdminCommandHandler
{
// private static final Logger _log = Logger.getLogger(AdminTeleport.class.getName());
private static final int REQUIRED_LEVEL = Config.GM_UNBLOCK;
private static String[] _adminCommands =
{
"admin_unblockip"
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM()))
{
return false;
}
}
if (command.startsWith("admin_unblockip "))
{
try
{
activeChar.sendMessage("Please remove the IP address of your choice from banned_ip.cfg file, and restart Login Server.");
}
catch (final StringIndexOutOfBoundsException e)
{
// Send syntax to the user
activeChar.sendMessage("Usage mode: //unblockip <ip>");
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return _adminCommands;
}
private boolean checkLevel(int level)
{
return (level >= REQUIRED_LEVEL);
}
}

View File

@@ -0,0 +1,130 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.MapRegionTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class AdminZone implements IAdminCommandHandler
{
private static final int REQUIRED_LEVEL = Config.GM_TEST;
public static final String[] ADMIN_ZONE_COMMANDS =
{
"admin_zone_check"
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jmobius.gameserver.model.L2PcInstance)
*/
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (activeChar == null)
{
return false;
}
if (!Config.ALT_PRIVILEGES_ADMIN)
{
if (activeChar.getAccessLevel() < REQUIRED_LEVEL)
{
return false;
}
}
final StringTokenizer st = new StringTokenizer(command, " ");
final String actualCommand = st.nextToken(); // Get actual command
if (actualCommand.equalsIgnoreCase("admin_zone_check"))
{
if (activeChar.isInsideZone(L2Character.ZONE_PVP))
{
activeChar.sendMessage("This is a PvP zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_NOLANDING))
{
activeChar.sendMessage("This is a non-landing zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_PEACE))
{
activeChar.sendMessage("This is a Peace zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_SIEGE))
{
activeChar.sendMessage("This is a Siege zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_MOTHERTREE))
{
activeChar.sendMessage("This is a Mother Tree zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_CLANHALL))
{
activeChar.sendMessage("This is a Clan Hall zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_WATER))
{
activeChar.sendMessage("This is a Water zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_JAIL))
{
activeChar.sendMessage("This is a Jail zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_MONSTERTRACK))
{
activeChar.sendMessage("This is a Monster Track zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_NOHQ))
{
activeChar.sendMessage("This is a Castle zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_UNUSED))
{
activeChar.sendMessage("This zone is not used.");
}
if (activeChar.isInsideZone(L2Character.ZONE_BOSS))
{
activeChar.sendMessage("This is a Boss zone.");
}
if (activeChar.isInsideZone(L2Character.ZONE_EFFECT))
{
activeChar.sendMessage("This is an Effect zone.");
}
activeChar.sendMessage("Closest Town: " + MapRegionTable.getInstance().getClosestTownName(activeChar));
}
return true;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
*/
@Override
public String[] getAdminCommandList()
{
return ADMIN_ZONE_COMMANDS;
}
}

View File

@@ -0,0 +1,147 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2BabyPetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* Beast SoulShot Handler
* @author Tempy
*/
public class BeastSoulShot implements IItemHandler
{
// All the item IDs that this handler knows.
private static int[] _itemIds =
{
6645
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (playable == null)
{
return;
}
L2PcInstance activeOwner = null;
if (playable instanceof L2Summon)
{
activeOwner = ((L2Summon) playable).getOwner();
activeOwner.sendPacket(new SystemMessage(SystemMessage.PET_CANNOT_USE_ITEM));
return;
}
else if (playable instanceof L2PcInstance)
{
activeOwner = (L2PcInstance) playable;
}
if (activeOwner == null)
{
return;
}
final L2Summon activePet = activeOwner.getPet();
if (activePet == null)
{
activeOwner.sendPacket(new SystemMessage(574));
return;
}
if (activePet.isDead())
{
activeOwner.sendPacket(new SystemMessage(1598));
return;
}
final int itemId = 6645;
final short shotConsumption = activePet.getSoulShotsPerHit();
final int shotCount = item.getCount();
if (shotCount < shotConsumption)
{
// Not enough Soulshots to use.
if (!activeOwner.disableAutoShot(itemId))
{
activeOwner.sendPacket(new SystemMessage(1701));
}
return;
}
L2ItemInstance weaponInst = null;
if ((activePet instanceof L2PetInstance) && !(activePet instanceof L2BabyPetInstance))
{
weaponInst = ((L2PetInstance) activePet).getActiveWeaponInstance();
}
if (weaponInst == null)
{
if (activePet.getChargedSoulShot() != L2ItemInstance.CHARGED_NONE)
{
return;
}
activePet.setChargedSoulShot(L2ItemInstance.CHARGED_SOULSHOT);
}
else
{
if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
{
// SoulShots are already active.
return;
}
weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_SOULSHOT);
}
// If the player doesn't have enough beast soulshot remaining, remove any auto soulshot task.
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
{
if (!activeOwner.disableAutoShot(itemId))
{
activeOwner.sendPacket(new SystemMessage(1701));
}
return;
}
// Pet uses the power of spirit.
activeOwner.sendPacket(new SystemMessage(1576));
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, 2033, 1, 0, 0), 360000/* 600 */);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,74 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2FeedableBeastInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class BeastSpice implements IItemHandler
{
// Golden Spice, Crystal Spice
private static int[] _itemIds =
{
6643,
6644
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
if (!(activeChar.getTarget() instanceof L2FeedableBeastInstance))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
return;
}
final L2Object[] targets = new L2Object[1];
targets[0] = activeChar.getTarget();
final int itemId = item.getItemId();
// Golden Spice
if (itemId == 6643)
{
activeChar.useMagic(SkillTable.getInstance().getInfo(2188, 1), false, false);
}
else if (itemId == 6644)
{
activeChar.useMagic(SkillTable.getInstance().getInfo(2189, 1), false, false);
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,168 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2BabyPetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* Beast SpiritShot Handler
* @author Tempy
*/
public class BeastSpiritShot implements IItemHandler
{
// All the item IDs that this handler knows.
private static int[] _itemIds =
{
6646,
6647
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (playable == null)
{
return;
}
L2PcInstance activeOwner = null;
if (playable instanceof L2PcInstance)
{
activeOwner = (L2PcInstance) playable;
}
else if (playable instanceof L2Summon)
{
activeOwner = ((L2Summon) playable).getOwner();
activeOwner.sendPacket(new SystemMessage(SystemMessage.PET_CANNOT_USE_ITEM));
return;
}
if (activeOwner == null)
{
return;
}
final L2Summon activePet = activeOwner.getPet();
if (activePet == null)
{
activeOwner.sendPacket(new SystemMessage(574));
return;
}
if (activePet.isDead())
{
activeOwner.sendPacket(new SystemMessage(1598));
return;
}
final int itemId = item.getItemId();
final boolean isBlessed = (itemId == 6647);
// Blessed Beast Spirit Shot cannot be used in olympiad.
if (isBlessed && activeOwner.isInOlympiadMode())
{
activeOwner.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
final short shotConsumption = activePet.getSpiritShotsPerHit();
final int shotCount = item.getCount();
if (shotCount < shotConsumption)
{
// Not enough SpiritShots to use.
if (!activeOwner.disableAutoShot(itemId))
{
activeOwner.sendPacket(new SystemMessage(1700));
}
return;
}
L2ItemInstance weaponInst = null;
if ((activePet instanceof L2PetInstance) && !(activePet instanceof L2BabyPetInstance))
{
weaponInst = ((L2PetInstance) activePet).getActiveWeaponInstance();
}
if (weaponInst == null)
{
if (activePet.getChargedSpiritShot() != L2ItemInstance.CHARGED_NONE)
{
return;
}
if (isBlessed)
{
activePet.setChargedSpiritShot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
}
else
{
activePet.setChargedSpiritShot(L2ItemInstance.CHARGED_SPIRITSHOT);
}
}
else
{
if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
{
// SpiritShots are already active.
return;
}
if (isBlessed)
{
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
}
else
{
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_SPIRITSHOT);
}
}
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
{
if (!activeOwner.disableAutoShot(itemId))
{
activeOwner.sendPacket(new SystemMessage(1700));
}
return;
}
// Pet uses the power of spirit.
activeOwner.sendPacket(new SystemMessage(1576));
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activePet, activePet, isBlessed ? 2009 : 2008, 1, 0, 0), 360000/* 600 */);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,129 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2Item;
import com.l2jmobius.gameserver.templates.L2Weapon;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.5 $ $Date: 2005/03/27 15:30:07 $
*/
public class BlessedSpiritShot implements IItemHandler
{
// all the items ids that this handler knowns
private static int[] _itemIds =
{
3947,
3948,
3949,
3950,
3951,
3952
};
private static int[] _skillIds =
{
2061,
2160,
2161,
2162,
2163,
2164
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final int itemId = item.getItemId();
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
// Check if Blessed Spiritshot can be used
if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANNOT_USE_SPIRITSHOTS));
}
return;
}
// Check if Blessed Spiritshot is already active (it can be charged over Spiritshot)
if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
{
return;
}
// Check for correct grade
final int weaponGrade = weaponItem.getCrystalType();
if (((weaponGrade == L2Item.CRYSTAL_NONE) && (itemId != 3947)) || ((weaponGrade == L2Item.CRYSTAL_D) && (itemId != 3948)) || ((weaponGrade == L2Item.CRYSTAL_C) && (itemId != 3949)) || ((weaponGrade == L2Item.CRYSTAL_B) && (itemId != 3950)) || ((weaponGrade == L2Item.CRYSTAL_A) && (itemId != 3951)) || ((weaponGrade == L2Item.CRYSTAL_S) && (itemId != 3952)))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.SPIRITSHOTS_GRADE_MISMATCH));
}
return;
}
// Consume Blessed Spiritshot if player has enough of them
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
{
if (!activeChar.disableAutoShot(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.NOT_ENOUGH_SPIRITSHOTS));
}
return;
}
// Charge Blessed Spiritshot
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
// Send message to client
activeChar.sendPacket(new SystemMessage(SystemMessage.ENABLED_SPIRITSHOT));
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, _skillIds[weaponGrade], 1, 0, 0), 360000/* 600 */);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
public class Book implements IItemHandler
{
private static final int[] ITEM_IDS =
{
5588,
6317,
7561,
7063,
7064,
7065,
7066,
7082,
7083,
7084,
7085,
7086,
7087,
7088,
7089,
7090,
7091,
7092,
7093,
7094,
7095,
7096,
7097,
7098,
7099,
7100,
7101,
7102,
7103,
7104,
7105,
7106,
7107,
7108,
7109,
7110,
7111,
7112
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
final String filename = "data/html/help/" + itemId + ".htm";
final String content = HtmCache.getInstance().getHtm(filename);
if (content == null)
{
final NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setHtml("<html><body>My Text is missing:<br>" + filename + "</body></html>");
activeChar.sendPacket(html);
}
else
{
final NpcHtmlMessage itemReply = new NpcHtmlMessage(5);
itemReply.setHtml(content);
activeChar.sendPacket(itemReply);
}
activeChar.sendPacket(new ActionFailed());
}
@Override
public int[] getItemIds()
{
return ITEM_IDS;
}
}

View File

@@ -0,0 +1,134 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
/**
* Itemhhandler for Character Appearance Change Potions
* @author Tempy
*/
public class CharChangePotions implements IItemHandler
{
private static int[] _itemIds =
{
5235,
5236,
5237, // Face
5238,
5239,
5240,
5241, // Hair Color
5242,
5243,
5244,
5245,
5246,
5247,
5248 // Hair Style
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
final int itemId = item.getItemId();
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
if (activeChar.isAllSkillsDisabled())
{
activeChar.sendPacket(new ActionFailed());
return;
}
switch (itemId)
{
case 5235:
activeChar.getAppearance().setFace(0);
break;
case 5236:
activeChar.getAppearance().setFace(1);
break;
case 5237:
activeChar.getAppearance().setFace(2);
break;
case 5238:
activeChar.getAppearance().setHairColor(0);
break;
case 5239:
activeChar.getAppearance().setHairColor(1);
break;
case 5240:
activeChar.getAppearance().setHairColor(2);
break;
case 5241:
activeChar.getAppearance().setHairColor(3);
break;
case 5242:
activeChar.getAppearance().setHairStyle(0);
break;
case 5243:
activeChar.getAppearance().setHairStyle(1);
break;
case 5244:
activeChar.getAppearance().setHairStyle(2);
break;
case 5245:
activeChar.getAppearance().setHairStyle(3);
break;
case 5246:
activeChar.getAppearance().setHairStyle(4);
break;
case 5247:
activeChar.getAppearance().setHairStyle(5);
break;
case 5248:
activeChar.getAppearance().setHairStyle(6);
break;
}
// Create a summon effect
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2003, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// Update the changed stat for the character in the DB.
activeChar.store();
// Remove the item from inventory.
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
// Broadcast the changes to the char and all those nearby.
activeChar.broadcastPacket(new UserInfo(activeChar));
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,93 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
/**
* @author AlterEgo
*/
public class ChestKey implements IItemHandler
{
public static final int INTERACTION_DISTANCE = 100;
private static int[] _itemIds =
{
5197,
5198,
5199,
5200,
5201,
5202,
5203,
5204, // chest key
6665,
6666,
6667,
6668,
6669,
6670,
6671,
6672 // deluxe key
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
final L2Skill skill = SkillTable.getInstance().getInfo(2229, itemId - 6664); // box key skill
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2ChestInstance))
{
activeChar.sendMessage("Invalid target.");
activeChar.sendPacket(new ActionFailed());
}
else
{
final L2ChestInstance chest = (L2ChestInstance) target;
if (chest.isDead() || chest.isInteracted())
{
activeChar.sendMessage("The chest is empty.");
activeChar.sendPacket(new ActionFailed());
return;
}
activeChar.useMagic(skill, false, false);
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,90 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:30:07 $
*/
public class CompBlessedSpiritShotPacks implements IItemHandler
{
private static int[] _itemIds =
{
5146,
5147,
5148,
5149,
5150,
5151,
5262,
5263,
5264,
5265,
5266,
5267
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
int itemToCreateId;
int amount;
if (itemId < 5200)
{ // Normal Compressed Package of SpiritShots
itemToCreateId = itemId - 1199; // Gives id of matching item for this pack
amount = 300;
}
else
{ // Greater Compressed Package of Spirithots
itemToCreateId = itemId - 1315; // Gives id of matching item for this pack
amount = 1000;
}
activeChar.getInventory().destroyItem("Extract", item, activeChar, null);
activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);
final SystemMessage sm = new SystemMessage(SystemMessage.EARNED_S2_S1_s);
sm.addItemName(itemToCreateId);
sm.addNumber(amount);
activeChar.sendPacket(sm);
final ItemList playerUI = new ItemList(activeChar, false);
activeChar.sendPacket(playerUI);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,107 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class CompShotPacks implements IItemHandler
{
private static int[] _itemIds =
{
5134,
5135,
5136,
5137,
5138,
5139,
//
5250,
5251,
5252,
5253,
5254,
5255 // SS
// 5140, 5141, 5142, 5143, 5144, 5145, /**/ 5256, 5257, 5258, 5259, 5260, 5261, // SpS
// 5146, 5147, 5148, 5149, 5150, 5151, /**/ 5262, 5263, 5264, 5265, 5266, 5267 // BSpS
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
L2PcInstance activeChar = (L2PcInstance) playable;
int itemId = item.getItemId();
int itemToCreateId = 0;
int amount = 0; // default regular pack
if ((itemId >= 5134) && (itemId <= 5139)) // SS
{
if (itemId == 5134)
{
itemToCreateId = 1835;
}
else
{
itemToCreateId = itemId - 3672;
}
amount = 300;
}
else if ((itemId >= 5250) && (itemId <= 5255)) // Greater SS
{
if (itemId == 5250)
{
itemToCreateId = 1835;
}
else
{
itemToCreateId = itemId - 3788;
}
amount = 1000;
}
// else if (itemId >= 5140 && itemId <= 5145) // SpS
// {} else if (itemId >= 5256 && itemId <= 5261) // Greater SpS
// {}
activeChar.getInventory().destroyItem("Extract", item, activeChar, null);
activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);
SystemMessage sm = new SystemMessage(SystemMessage.EARNED_S2_S1_s);
sm.addItemName(itemToCreateId);
sm.addNumber(amount);
activeChar.sendPacket(sm);
ItemList playerUI = new ItemList(activeChar, false);
activeChar.sendPacket(playerUI);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,90 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:30:07 $
*/
public class CompSpiritShotPacks implements IItemHandler
{
private static int[] _itemIds =
{
5140,
5141,
5142,
5143,
5144,
5145,
5256,
5257,
5258,
5259,
5260,
5261
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
int itemToCreateId;
int amount;
if (itemId < 5200)
{ // Normal Compressed Package of SpiritShots
itemToCreateId = itemId - 2631; // Gives id of matching item for this pack
amount = 300;
}
else
{ // Greater Compressed Package of Spirithots
itemToCreateId = itemId - 2747; // Gives id of matching item for this pack
amount = 1000;
}
activeChar.getInventory().destroyItem("Extract", item, activeChar, null);
activeChar.getInventory().addItem("Extract", itemToCreateId, amount, activeChar, item);
final SystemMessage sm = new SystemMessage(SystemMessage.EARNED_S2_S1_s);
sm.addItemName(itemToCreateId);
sm.addNumber(amount);
activeChar.sendPacket(sm);
final ItemList playerUI = new ItemList(activeChar, false);
activeChar.sendPacket(playerUI);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,200 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
/**
* This class ...
* @version $Revision: 1.2.4.4 $ $Date: 2005/03/27 15:30:07 $
*/
public class CrystalCarol implements IItemHandler
{
private static int[] _itemIds =
{
5562,
5563,
5564,
5565,
5566,
5583,
5584,
5585,
5586,
5587,
4411,
4412,
4413,
4414,
4415,
4416,
4417,
5010,
6903,
7061,
7062
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
if (itemId == 5562)
{ // crystal_carol_01
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2140, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_01");
}
else if (itemId == 5563)
{ // crystal_carol_02
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2141, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_02");
}
else if (itemId == 5564)
{ // crystal_carol_03
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2142, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_03");
}
else if (itemId == 5565)
{ // crystal_carol_04
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2143, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_04");
}
else if (itemId == 5566)
{ // crystal_carol_05
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2144, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_05");
}
else if (itemId == 5583)
{ // crystal_carol_06
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2145, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_06");
}
else if (itemId == 5584)
{ // crystal_carol_07
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2146, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_07");
}
else if (itemId == 5585)
{ // crystal_carol_08
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2147, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_08");
}
else if (itemId == 5586)
{ // crystal_carol_09
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2148, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_09");
}
else if (itemId == 5587)
{ // crystal_carol_10
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2149, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_carol_10");
}
else if (itemId == 4411)
{ // crystal_journey
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2069, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_journey");
}
else if (itemId == 4412)
{ // crystal_battle
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2068, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_battle");
}
else if (itemId == 4413)
{ // crystal_love
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2070, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_love");
}
else if (itemId == 4414)
{ // crystal_solitude
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2072, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_solitude");
}
else if (itemId == 4415)
{ // crystal_festival
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2071, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_festival");
}
else if (itemId == 4416)
{ // crystal_celebration
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2073, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_celebration");
}
else if (itemId == 4417)
{ // crystal_comedy
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2067, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_comedy");
}
else if (itemId == 5010)
{ // crystal_victory
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2066, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_victory");
}
else if (itemId == 6903)
{ // music_box_m
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2187, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"EtcSound.battle");
}
else if (itemId == 7061)
{ // crystal_birthday
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2073, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound2.crystal_celebration");
}
else if (itemId == 7062)
{ // crystal_wedding
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2230, 1, 1, 0);
activeChar.broadcastPacket(MSU);
// playCrystalSound(activeChar,"SkillSound5.wedding");
}
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,87 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ChooseInventoryItem;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class EnchantScrolls implements IItemHandler
{
private static int[] _itemIds =
{
729,
730,
731,
732,
6569,
6570, // a grade
947,
948,
949,
950,
6571,
6572, // b grade
951,
952,
953,
954,
6573,
6574, // c grade
955,
956,
957,
958,
6575,
6576, // d grade
959,
960,
961,
962,
6577,
6578 // s grade
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
if (activeChar.isCastingNow())
{
return;
}
activeChar.setActiveEnchantItem(item);
activeChar.sendPacket(new SystemMessage(SystemMessage.SELECT_ITEM_TO_ENCHANT));
activeChar.sendPacket(new ChooseInventoryItem(item.getItemId()));
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,85 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class EnergyStone implements IItemHandler
{
private static int[] _itemIds =
{
5589
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
L2PcInstance activeChar = null;
if (playable instanceof L2PcInstance)
{
activeChar = (L2PcInstance) playable;
}
else if (playable instanceof L2PetInstance)
{
activeChar = ((L2PetInstance) playable).getOwner();
}
if (activeChar == null)
{
return;
}
if (item.getItemId() != 5589)
{
return;
}
if (activeChar.isAllSkillsDisabled())
{
return;
}
if (activeChar.isSitting())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANT_MOVE_SITTING));
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(2165, 1);
if (skill != null)
{
activeChar.useMagic(skill, false, false);
}
activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,128 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import java.util.logging.Logger;
import com.l2jmobius.gameserver.datatables.ExtractableItemsData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ExtractableItem;
import com.l2jmobius.gameserver.model.L2ExtractableProductItem;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.util.Rnd;
/**
* @author FBIagent 11/12/2006
*/
public class ExtractableItems implements IItemHandler
{
private static Logger _log = Logger.getLogger(ItemTable.class.getName());
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemID = item.getItemId();
final L2ExtractableItem exitem = ExtractableItemsData.getInstance().getExtractableItem(itemID);
if (exitem == null)
{
return;
}
int createItemID = 0;
int createAmount = 0;
final int rndNum = Rnd.get(100);
int chanceFrom = 0;
// calculate extraction
for (final L2ExtractableProductItem expi : exitem.getProductItemsArray())
{
final int chance = expi.getChance();
if ((rndNum >= chanceFrom) && (rndNum <= (chance + chanceFrom)))
{
createItemID = expi.getId();
createAmount = expi.getAmmount();
break;
}
chanceFrom += chance;
}
if (createItemID <= 0)
{
activeChar.sendMessage("Nothing happened.");
return;
}
if (ItemTable.getInstance().createDummyItem(createItemID) == null)
{
_log.warning("createItemID " + createItemID + " doesn't have template!");
activeChar.sendMessage("Nothing happened.");
return;
}
if (!activeChar.destroyItemByItemId("Extract", itemID, 1, activeChar.getTarget(), true))
{
return;
}
if (ItemTable.getInstance().createDummyItem(createItemID).isStackable())
{
activeChar.addItem("Extract", createItemID, createAmount, item, false);
}
else
{
for (int i = 0; i < createAmount; i++)
{
activeChar.addItem("Extract", createItemID, 1, item, false);
}
}
SystemMessage sm;
if (createAmount > 1)
{
sm = new SystemMessage(SystemMessage.EARNED_S2_S1_s);
sm.addItemName(createItemID);
sm.addNumber(createAmount);
}
else
{
sm = new SystemMessage(SystemMessage.EARNED_ITEM);
sm.addItemName(createItemID);
}
activeChar.sendPacket(sm);
}
@Override
public int[] getItemIds()
{
return ExtractableItemsData.getInstance().itemIDs();
}
}

View File

@@ -0,0 +1,114 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
/**
* This class ...
* @version $Revision: 1.0.0.0.0.0 $ $Date: 2005/09/02 19:41:13 $
*/
public class Firework implements IItemHandler
{
// Modified by Baghak (Prograsso): Added Firework support
private static int[] _itemIds =
{
6403,
6406,
6407
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return; // prevent Class cast exception
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
if (!activeChar.getFloodProtectors().getFirework().tryPerformAction("firework"))
{
return;
}
/*
* Elven Firecracker
*/
if (itemId == 6403) // elven_firecracker, xml: 2023
{
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2023, 1, 1, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
useFw(activeChar, item, 2023, 1);
}
/*
* Firework
*/
else if (itemId == 6406) // firework, xml: 2024
{
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2024, 1, 1, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
useFw(activeChar, item, 2024, 1);
}
/*
* Lage Firework
*/
else if (itemId == 6407) // large_firework, xml: 2025
{
final MagicSkillUse MSU = new MagicSkillUse(playable, activeChar, 2025, 1, 1, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
useFw(activeChar, item, 2025, 1);
}
}
public void useFw(L2PcInstance activeChar, L2ItemInstance item, int magicId, int level)
{
final L2Skill skill = SkillTable.getInstance().getInfo(magicId, level);
if (skill != null)
{
if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.useMagic(skill, false, false);
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,116 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2Item;
import com.l2jmobius.gameserver.templates.L2Weapon;
import com.l2jmobius.gameserver.templates.L2WeaponType;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* @author -Nemesiss-
*/
public class FishShots implements IItemHandler
{
// All the item IDs that this handler knows.
private static int[] _itemIds =
{
6535,
6536,
6537,
6538,
6539,
6540
};
private static int[] _skillIds =
{
2181,
2182,
2183,
2184,
2185,
2186
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
if ((weaponInst == null) || (weaponItem.getItemType() != L2WeaponType.ROD))
{
return;
}
if (weaponInst.getChargedFishshot())
{
// spiritshot is already active
return;
}
final int FishshotId = item.getItemId();
final int grade = weaponItem.getCrystalType();
final int count = item.getCount();
if (((grade == L2Item.CRYSTAL_NONE) && (FishshotId != 6535)) || ((grade == L2Item.CRYSTAL_D) && (FishshotId != 6536)) || ((grade == L2Item.CRYSTAL_C) && (FishshotId != 6537)) || ((grade == L2Item.CRYSTAL_B) && (FishshotId != 6538)) || ((grade == L2Item.CRYSTAL_A) && (FishshotId != 6539)) || ((grade == L2Item.CRYSTAL_S) && (FishshotId != 6540)))
{
// 1479 - This fishing shot is not fit for the fishing pole crystal.
activeChar.sendPacket(new SystemMessage(SystemMessage.WRONG_FISHINGSHOT_GRADE));
return;
}
if (count < 1)
{
return;
}
weaponInst.setChargedFishshot(true);
activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), 1, null, false);
final L2Object oldTarget = activeChar.getTarget();
activeChar.setTarget(activeChar);
// activeChar.sendPacket(new SystemMessage(SystemMessage.ENABLED_SPIRITSHOT));
final MagicSkillUse MSU = new MagicSkillUse(activeChar, _skillIds[grade], 1, 0, 0);
Broadcast.toSelfAndKnownPlayers(activeChar, MSU);
activeChar.setTarget(oldTarget);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,78 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class Harvester implements IItemHandler
{
private static int[] _itemIds =
{
5125
};
L2PcInstance _activeChar;
L2MonsterInstance _target;
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance _item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
if (CastleManorManager.getInstance().isDisabled())
{
return;
}
_activeChar = (L2PcInstance) playable;
if ((_activeChar.getTarget() == null) || !(_activeChar.getTarget() instanceof L2MonsterInstance))
{
_activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
_activeChar.sendPacket(new ActionFailed());
return;
}
_target = (L2MonsterInstance) _activeChar.getTarget();
if ((_target == null) || !_target.isDead())
{
_activeChar.sendPacket(new ActionFailed());
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(2098, 1); // harvesting skill
_activeChar.useMagic(skill, false, false);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,134 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.MercTicketManager;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.model.entity.Castle;
public class MercTicket implements IItemHandler
{
private static String[] _Messages =
{
"To arms!.",
"I am ready to serve you my lord when the time comes.",
"You summon me."
};
/**
* handler for using mercenary tickets. Things to do: 1) Check constraints: 1.a) Tickets may only be used in a castle 1.b) Only specific tickets may be used in each castle (different tickets for each castle) 1.c) only the owner of that castle may use them 1.d) tickets cannot be used during siege
* 1.e) Check if max number of tickets has been reached 1.f) Check if max number of tickets from this ticket's TYPE has been reached 2) If allowed, call the MercTicketManager to add the item and spawn in the world 3) Remove the item from the person's inventory
*/
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
final int itemId = item.getItemId();
final L2PcInstance activeChar = (L2PcInstance) playable;
final Castle castle = CastleManager.getInstance().getCastle(activeChar);
int castleId = -1;
if (castle != null)
{
castleId = castle.getCastleId();
}
if (castleId == -1)
{
activeChar.sendMessage("Mercenary Tickets can only be used in castles.");
return;
}
// add check that certain tickets can only be placed in certain castles
if (MercTicketManager.getInstance().getTicketCastleId(itemId) != castleId)
{
String castleName = null;
switch (MercTicketManager.getInstance().getTicketCastleId(itemId))
{
case 1:
castleName = "Gludio";
break;
case 2:
castleName = "Dion";
break;
case 3:
castleName = "Giran";
break;
case 4:
castleName = "Oren";
break;
case 5:
castleName = "Aden";
break;
case 6:
castleName = "Innadril";
break;
case 7:
castleName = "Goddard";
break;
}
activeChar.sendMessage("This Mercenary Ticket can only be used in " + castleName + " castle.");
return;
}
if (!activeChar.isCastleLord(castleId))
{
activeChar.sendMessage("You are not the lord of this castle.");
return;
}
if ((castle != null) && castle.getSiege().getIsInProgress())
{
activeChar.sendMessage("You cannot hire a mercenary while siege is in progress.");
return;
}
if (MercTicketManager.getInstance().isAtCastleLimit(item.getItemId()))
{
activeChar.sendMessage("You cannot hire any more mercenaries.");
return;
}
if (MercTicketManager.getInstance().isAtTypeLimit(item.getItemId()))
{
activeChar.sendMessage("You cannot hire any more mercenaries of this type.You may still hire other types of mercenaries.");
return;
}
if (MercTicketManager.getInstance().isTooCloseToAnotherTicket(activeChar.getX(), activeChar.getY(), activeChar.getZ()))
{
activeChar.sendMessage("The distance between mercenaries is too short.");
return;
}
final int npcId = MercTicketManager.getInstance().addTicket(item.getItemId(), activeChar, _Messages);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false); // Remove item from char's inventory
activeChar.sendMessage("Hired mercenary (" + itemId + "," + npcId + ") at coords:" + activeChar.getX() + "," + activeChar.getY() + "," + activeChar.getZ() + " heading:" + activeChar.getHeading());
}
// left in here for backward compatibility
@Override
public int[] getItemIds()
{
return MercTicketManager.getInstance().getItemIds();
}
}

View File

@@ -0,0 +1,154 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2PetDataTable;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author Kerberos
*/
public class PetFood implements IItemHandler
{
private static final int[] ITEM_IDS =
{
2515,
4038,
5168,
5169,
6316,
7582
};
/**
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
final int itemId = item.getItemId();
switch (itemId)
{
case 2515: // Wolf's food
useFood(playable, 2048, item);
break;
case 4038: // Hatchling's food
useFood(playable, 2063, item);
break;
case 5168: // Strider's food
useFood(playable, 2101, item);
break;
case 5169: // ClanHall / Castle Strider's food
useFood(playable, 2102, item);
break;
case 6316: // Wyvern's food
useFood(playable, 2180, item);
break;
case 7582: // Baby Pet's food
useFood(playable, 2048, item);
break;
}
}
public boolean useFood(L2PlayableInstance activeChar, int magicId, L2ItemInstance item)
{
final L2Skill skill = SkillTable.getInstance().getInfo(magicId, 1);
if (skill != null)
{
if (activeChar instanceof L2PetInstance)
{
if (((L2PetInstance) activeChar).destroyItem("Consume", item.getObjectId(), 1, null, false))
{
activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, magicId, 1, 0, 0));
((L2PetInstance) activeChar).setCurrentFed(((L2PetInstance) activeChar).getCurrentFed() + skill.getFeed());
((L2PetInstance) activeChar).broadcastStatusUpdate();
if (((L2PetInstance) activeChar).getCurrentFed() < (0.55 * ((L2PetInstance) activeChar).getPetData().getPetMaxFeed()))
{
((L2PetInstance) activeChar).getOwner().sendPacket(new SystemMessage(SystemMessage.YOUR_PET_ATE_A_LITTLE_BUT_IS_STILL_HUNGRY));
}
return true;
}
}
else if (activeChar instanceof L2PcInstance)
{
final L2PcInstance player = ((L2PcInstance) activeChar);
final int itemId = item.getItemId();
boolean canUse = false;
if (player.isMounted())
{
final int petId = player.getMountNpcId();
if (L2PetDataTable.isWolf(petId) && L2PetDataTable.isWolfFood(itemId))
{
canUse = true;
}
else if (L2PetDataTable.isSinEater(petId) && L2PetDataTable.isSinEaterFood(itemId))
{
canUse = true;
}
else if (L2PetDataTable.isHatchling(petId) && L2PetDataTable.isHatchlingFood(itemId))
{
canUse = true;
}
else if (L2PetDataTable.isStrider(petId) && L2PetDataTable.isStriderFood(itemId))
{
canUse = true;
}
else if (L2PetDataTable.isWyvern(petId) && L2PetDataTable.isWyvernFood(itemId))
{
canUse = true;
}
else if (L2PetDataTable.isBaby(petId) && L2PetDataTable.isBabyFood(itemId))
{
canUse = true;
}
if (canUse)
{
if (player.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
player.broadcastPacket(new MagicSkillUse(activeChar, activeChar, magicId, 1, 0, 0));
player.setCurrentFeed(player.getCurrentFeed() + skill.getFeed());
}
return true;
}
activeChar.sendPacket(new SystemMessage(SystemMessage.S1_CANNOT_BE_USED));
return false;
}
player.sendPacket(new SystemMessage(SystemMessage.S1_CANNOT_BE_USED));
return false;
}
}
return false;
}
/**
* @see com.l2jmobius.gameserver.handler.IItemHandler#getItemIds()
*/
@Override
public int[] getItemIds()
{
return ITEM_IDS;
}
}

View File

@@ -0,0 +1,328 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.handler.ISkillHandler;
import com.l2jmobius.gameserver.handler.SkillHandler;
import com.l2jmobius.gameserver.model.L2Effect;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.2.4.4 $ $Date: 2005/03/27 15:30:07 $
*/
public class Potions implements IItemHandler
{
private static int[] _itemIds =
{
65,
725,
726,
727,
728,
734,
735,
1060,
1061,
1062,
1073,
1374,
1375,
1539,
1540,
5234,
5283,
5591,
5592,
6035,
6036
};
@Override
public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
L2PcInstance activeChar = null;
if (playable instanceof L2PcInstance)
{
activeChar = (L2PcInstance) playable;
}
else if (playable instanceof L2PetInstance)
{
activeChar = ((L2PetInstance) playable).getOwner();
}
if (activeChar == null)
{
return;
}
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.getEventTeam() > 0)
{
activeChar.sendMessage("You cannot use this item in the TvT Event.");
return;
}
final int itemId = item.getItemId();
// Mana potions
if (itemId == 726)
{
usePotion(playable, item, 2003, 1); // configurable through xml till handler implemented
}
else if (itemId == 728)
{
usePotion(playable, item, 2005, 1);
// Healing and speed potions
}
else if (itemId == 65)
{
usePotion(playable, item, 2001, 1);
}
else if (itemId == 725) // healing_drug, xml: 2002
{
if (!isEffectReplaceable(activeChar, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
{
return;
}
usePotion(playable, item, 2002, 1);
}
else if (itemId == 727) // _healing_potion, xml: 2032
{
if (!isEffectReplaceable(activeChar, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
{
return;
}
usePotion(playable, item, 2032, 1);
}
else if (itemId == 734)
{
usePotion(playable, item, 2011, 1);
}
else if (itemId == 735)
{
usePotion(playable, item, 2012, 1);
}
else if ((itemId == 1060) || (itemId == 1073)) // lesser_healing_potion, beginner's potion, xml: 2031
{
if (!isEffectReplaceable(activeChar, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
{
return;
}
usePotion(playable, item, 2031, 1);
}
else if (itemId == 1061) // healing_potion, xml: 2032
{
if (!isEffectReplaceable(activeChar, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
{
return;
}
usePotion(playable, item, 2032, 1);
}
else if (itemId == 1062)
{
usePotion(playable, item, 2033, 1);
}
else if (itemId == 1374)
{
usePotion(playable, item, 2034, 1);
}
else if (itemId == 1375)
{
usePotion(playable, item, 2035, 1);
}
else if (itemId == 1539) // greater_healing_potion, xml: 2037
{
if (!isEffectReplaceable(activeChar, L2Effect.EffectType.HEAL_OVER_TIME, itemId))
{
return;
}
usePotion(playable, item, 2037, 1);
}
else if (itemId == 1540)
{
usePotion(playable, item, 2038, 1);
}
else if (itemId == 5234)
{
usePotion(playable, item, 2103, 1);
}
else if (itemId == 5283)
{
useCake(playable, item);
}
else if ((itemId == 5591) || (itemId == 5592)) // CP and Greater CP Potion
{
// Leave it here just in case of admins changing skill usage
if (!isEffectReplaceable(activeChar, L2Effect.EffectType.COMBAT_POINT_HEAL_OVER_TIME, itemId))
{
return;
}
usePotion(playable, item, 2166, (itemId == 5591) ? 1 : 2);
}
else if (itemId == 6035)
{
usePotion(playable, item, 2169, 1);
}
else if (itemId == 6036)
{
usePotion(playable, item, 2169, 2);
}
}
private void usePotion(L2PlayableInstance activeChar, L2ItemInstance item, int magicId, int level)
{
final L2Skill skill = SkillTable.getInstance().getInfo(magicId, level);
if (skill != null)
{
if (activeChar.isSkillDisabled(skill.getId(), false))
{
final SystemMessage sm = new SystemMessage(SystemMessage.S1_PREPARED_FOR_REUSE);
sm.addSkillName(skill.getId(), skill.getLevel());
activeChar.sendPacket(sm);
return;
}
if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
if (activeChar instanceof L2PcInstance)
{
final SystemMessage sm = new SystemMessage(SystemMessage.USE_S1);
sm.addItemName(item.getItemId());
activeChar.sendPacket(sm);
}
if (skill.getReuseDelay() > 10)
{
activeChar.disableSkill(skill.getId(), skill.getReuseDelay());
}
activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, skill.getId(), skill.getLevel(), skill.getHitTime(), 0));
// Apply effects
try
{
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType());
if (handler != null)
{
handler.useSkill(activeChar, skill, new L2PlayableInstance[]
{
activeChar
}, false);
}
}
catch (final Exception e)
{
}
}
}
private boolean isEffectReplaceable(L2PlayableInstance playable, Enum<?> effectType, int itemId)
{
final L2Effect[] effects = playable.getAllEffects();
if (effects == null)
{
return true;
}
final L2PcInstance activeChar = (L2PcInstance) ((playable instanceof L2PcInstance) ? playable : ((L2Summon) playable).getOwner());
for (final L2Effect e : effects)
{
if (e.getEffectType() == effectType)
{
// One can reuse pots after 2/3 of their duration is over.
// It would be faster to check if its > 10 but that would screw custom pot durations...
if (e.getTaskTime() > ((e.getSkill().getBuffDuration() * 67) / 100000))
{
return true;
}
final SystemMessage sm = new SystemMessage(48);
sm.addItemName(itemId);
activeChar.sendPacket(sm);
return false;
}
}
return true;
}
private void useCake(L2PlayableInstance playable, L2ItemInstance item)
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
if (playable instanceof L2PcInstance)
{
final SystemMessage sm = new SystemMessage(SystemMessage.USE_S1);
sm.addItemName(item.getItemId());
playable.sendPacket(sm);
}
playable.broadcastPacket(new MagicSkillUse(playable, playable, 2136, 1, 0, 0));
// Restore HP by 3%
final double hp = (playable.getMaxHp() * 3) / 100.0;
playable.setCurrentHp(hp + playable.getCurrentHp());
// Restore MP by 5%
final double mp = (playable.getMaxMp() * 5) / 100.0;
playable.setCurrentMp(mp + playable.getCurrentMp());
final StatusUpdate su = new StatusUpdate(playable.getObjectId());
su.addAttribute(StatusUpdate.CUR_HP, (int) playable.getCurrentHp());
su.addAttribute(StatusUpdate.CUR_MP, (int) playable.getCurrentMp());
playable.sendPacket(su);
playable.sendMessage("Restored " + (int) hp + " HP and " + (int) mp + " MP.");
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,135 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.RecipeController;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2RecipeList;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.1.2.5.2.5 $ $Date: 2005/04/06 16:13:51 $
*/
public class Recipes implements IItemHandler
{
private static int[] _itemIds = null;
public Recipes()
{
final RecipeController rc = RecipeController.getInstance();
_itemIds = new int[rc.getRecipesCount()];
for (int i = 0; i < rc.getRecipesCount(); i++)
{
_itemIds[i] = rc.getRecipeList(i).getRecipeId();
}
}
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final L2RecipeList rp = RecipeController.getInstance().getRecipeByItemId(item.getItemId());
if (rp == null)
{
return;
}
if (activeChar.hasRecipeList(rp.getId()))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.RECIPE_ALREADY_REGISTERED));
}
else
{
if (rp.isDwarvenRecipe())
{
if (activeChar.hasDwarvenCraft())
{
if (rp.getLevel() > activeChar.getDwarvenCraft())
{
// can't add recipe, because create item level too low
activeChar.sendPacket(new SystemMessage(404));
}
else if (activeChar.getDwarvenRecipeBook().length >= activeChar.getDwarfRecipeLimit())
{
// Up to $s1 recipes can be registered.
final SystemMessage sm = new SystemMessage(894);
sm.addNumber(activeChar.getDwarfRecipeLimit());
activeChar.sendPacket(sm);
}
else
{
activeChar.registerDwarvenRecipeList(rp, true);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
final SystemMessage sm = new SystemMessage(SystemMessage.S1_HAS_BEEN_ADDED);
sm.addItemName(item.getItemId());
activeChar.sendPacket(sm);
}
}
else
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANT_REGISTER_NO_ABILITY_TO_CRAFT));
}
}
else
{
if (activeChar.hasCommonCraft())
{
if (rp.getLevel() > activeChar.getCommonCraft())
{
// can't add recipe, because create item level too low
activeChar.sendPacket(new SystemMessage(404));
}
else if (activeChar.getCommonRecipeBook().length >= activeChar.getCommonRecipeLimit())
{
// Up to $s1 recipes can be registered.
final SystemMessage sm = new SystemMessage(894);
sm.addNumber(activeChar.getCommonRecipeLimit());
activeChar.sendPacket(sm);
}
else
{
activeChar.registerCommonRecipeList(rp, true);
activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
final SystemMessage sm = new SystemMessage(SystemMessage.S1_HAS_BEEN_ADDED);
sm.addItemName(item.getItemId());
activeChar.sendPacket(sm);
}
}
else
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANT_REGISTER_NO_ABILITY_TO_CRAFT));
}
}
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,129 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.1.2.4 $ $Date: 2005/04/06 16:13:51 $
*/
public class Remedy implements IItemHandler
{
private static int[] _itemIds =
{
1831,
1832,
1833,
1834,
3889,
6654
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
L2PcInstance activeChar;
if (playable instanceof L2PcInstance)
{
activeChar = (L2PcInstance) playable;
}
else if (playable instanceof L2PetInstance)
{
activeChar = ((L2PetInstance) playable).getOwner();
}
else
{
return;
}
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.getEventTeam() > 0)
{
return;
}
final int itemId = item.getItemId();
if (itemId == 1831) // antidote
{
activeChar.negateEffects(L2Skill.SkillType.POISON, 3, 0);
final MagicSkillUse MSU = new MagicSkillUse(playable, playable, 2042, 1, 0, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
else if (itemId == 1832) // advanced antidote
{
activeChar.negateEffects(L2Skill.SkillType.POISON, 7, 0);
final MagicSkillUse MSU = new MagicSkillUse(playable, playable, 2043, 1, 0, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
else if (itemId == 1833) // bandage
{
activeChar.negateEffects(L2Skill.SkillType.BLEED, 3, 0);
final MagicSkillUse MSU = new MagicSkillUse(playable, playable, 34, 1, 0, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
else if (itemId == 1834) // emergency dressing
{
activeChar.negateEffects(L2Skill.SkillType.BLEED, 7, 0);
final MagicSkillUse MSU = new MagicSkillUse(playable, playable, 2045, 1, 0, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
else if (itemId == 3889) // potion of recovery
{
activeChar.stopSkillEffects(4082);
final MagicSkillUse MSU = new MagicSkillUse(playable, playable, 2042, 1, 0, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
else if (itemId == 6654) // Amulet: Flames of Valakas
{
activeChar.stopSkillEffects(4683);
activeChar.stopSkillEffects(4684);
final MagicSkillUse MSU = new MagicSkillUse(playable, playable, 2233, 1, 0, 0);
activeChar.sendPacket(MSU);
activeChar.broadcastPacket(MSU);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,97 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.Dice;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.util.Rnd;
/**
* This class ...
* @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:07 $
*/
public class RollingDice implements IItemHandler
{
private static int[] _itemIds =
{
4625,
4626,
4627,
4628
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if ((itemId == 4625) || (itemId == 4626) || (itemId == 4627) || (itemId == 4628))
{
if (!activeChar.getFloodProtectors().getRollDice().tryPerformAction("roll dice"))
{
activeChar.sendPacket(new SystemMessage(835));
return;
}
final int number = Rnd.get(1, 6);
final Dice d = new Dice(activeChar.getObjectId(), item.getItemId(), number, activeChar.getX() - 30, activeChar.getY() - 30, activeChar.getZ());
Broadcast.toSelfAndKnownPlayers(activeChar, d);
final SystemMessage sm = new SystemMessage(SystemMessage.S1_ROLLED_S2);
sm.addString(activeChar.getName());
sm.addNumber(number);
activeChar.sendPacket(sm);
if (activeChar.isInsideZone(L2Character.ZONE_PEACE))
{
Broadcast.toKnownPlayers(activeChar, sm);
}
else if (activeChar.isInParty())
{
activeChar.getParty().broadcastToPartyMembers(activeChar, sm);
}
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,320 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.datatables.MapRegionTable;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SetupGauge;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.2.2.3.2.5 $ $Date: 2005/03/27 15:30:07 $
*/
public class ScrollOfEscape implements IItemHandler
{
// all the items ids that this handler knowns
private static int[] _itemIds =
{
736,
1830,
1829,
1538,
3958,
5858,
5859,
7117,
7118,
7119,
7120,
7121,
7122,
7123,
7124,
7125,
7126,
7127,
7128,
7129,
7130,
7131,
7132,
7133,
7134,
7554,
7555,
7556,
7557,
7558,
7559,
7618,
7619
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
if (activeChar.isMovementDisabled() || activeChar.isAlikeDead() || activeChar.isAllSkillsDisabled())
{
return;
}
if (activeChar.isSitting())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANT_MOVE_SITTING));
return;
}
if ((activeChar.isInParty() && activeChar.getParty().isInDimensionalRift()) || DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), true))
{
activeChar.sendMessage("Once a party is ported in another dimension, its members cannot get out of it.");
return;
}
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.getEventTeam() > 0)
{
activeChar.sendMessage("You may not use an escape skill in TvT Event.");
return;
}
// Check to see if the player is in a festival.
if (activeChar.isFestivalParticipant())
{
activeChar.sendMessage("You may not use an escape skill in a festival.");
return;
}
// Check to see if player is in jail
if (activeChar.isInJail())
{
activeChar.sendMessage("You cannot escape from jail.");
return;
}
// Modified by Tempy - 28 Jul 05 \\
// Check if this is a blessed scroll, if it is then shorten the cast time.
final int itemId = item.getItemId();
final int escapeSkill = ((itemId == 1538) || (itemId == 5858) || (itemId == 5859) || (itemId == 3958)) ? 2036 : 2013;
final L2Skill skill = SkillTable.getInstance().getInfo(escapeSkill, 1);
if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
activeChar.setTarget(activeChar);
activeChar.disableAllSkills();
activeChar.broadcastPacket(new MagicSkillUse(activeChar, skill.getId(), 1, skill.getHitTime(), 0));
activeChar.sendPacket(new SetupGauge(0, skill.getHitTime()));
final SystemMessage sm = new SystemMessage(SystemMessage.S1_DISAPPEARED);
sm.addItemName(itemId);
activeChar.sendPacket(sm);
final EscapeFinalizer ef = new EscapeFinalizer(activeChar, itemId);
// continue execution later
activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleEffect(ef, skill.getHitTime()));
activeChar.setSkillCastEndTime(10 + GameTimeController.getGameTicks() + (skill.getHitTime() / GameTimeController.MILLIS_IN_TICK));
}
static class EscapeFinalizer implements Runnable
{
private final L2PcInstance _activeChar;
private final int _itemId;
EscapeFinalizer(L2PcInstance activeChar, int itemId)
{
_activeChar = activeChar;
_itemId = itemId;
}
@Override
public void run()
{
if (_activeChar.isDead())
{
return;
}
_activeChar.enableAllSkills();
try
{
switch (_itemId)
{
case 1829:
case 5858:
if (_activeChar.getClan().getHasHideout() == 0)
{
_activeChar.sendMessage("The clan does not own a clan hall.");
}
_activeChar.teleToLocation(MapRegionTable.TeleportWhereType.ClanHall);
break;
case 1830:
case 5859:
if (_activeChar.getClan().getHasCastle() == 0)
{
_activeChar.sendMessage("The clan does not own a castle.");
}
_activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Castle);
break;
case 7117:
_activeChar.teleToLocation(-84318, 244579, -3730, true); // Talking Island
break;
case 7554:
_activeChar.teleToLocation(-84318, 244579, -3730, true); // Talking Island quest scroll
break;
case 7118:
_activeChar.teleToLocation(46934, 51467, -2977, true); // Elven Village
break;
case 7555:
_activeChar.teleToLocation(46934, 51467, -2977, true); // Elven Village quest scroll
break;
case 7119:
_activeChar.teleToLocation(9745, 15606, -4574, true); // Dark Elven Village
break;
case 7556:
_activeChar.teleToLocation(9745, 15606, -4574, true); // Dark Elven Village quest scroll
break;
case 7120:
_activeChar.teleToLocation(-44836, -112524, -235, true); // Orc Village
break;
case 7557:
_activeChar.teleToLocation(-44836, -112524, -235, true); // Orc Village quest scroll
break;
case 7121:
_activeChar.teleToLocation(115113, -178212, -901, true); // Dwarven Village
break;
case 7558:
_activeChar.teleToLocation(115113, -178212, -901, true); // Dwarven Village quest scroll
break;
case 7122:
_activeChar.teleToLocation(-80826, 149775, -3043, true); // Gludin Village
break;
case 7123:
_activeChar.teleToLocation(-12678, 122776, -3116, true); // Gludio Castle Town
break;
case 7124:
_activeChar.teleToLocation(15670, 142983, -2705, true); // Dion Castle Town
break;
case 7125:
_activeChar.teleToLocation(17836, 170178, -3507, true); // Floran
break;
case 7126:
_activeChar.teleToLocation(83400, 147943, -3404, true); // Giran Castle Town
break;
case 7559:
_activeChar.teleToLocation(83400, 147943, -3404, true); // Giran Castle Town quest scroll
break;
case 7127:
_activeChar.teleToLocation(105918, 109759, -3207, true); // Hardin's Private Academy
break;
case 7128:
_activeChar.teleToLocation(111409, 219364, -3545, true); // Heine
break;
case 7129:
_activeChar.teleToLocation(82956, 53162, -1495, true); // Oren Castle Town
break;
case 7130:
_activeChar.teleToLocation(85348, 16142, -3699, true); // Ivory Tower
break;
case 7131:
_activeChar.teleToLocation(116819, 76994, -2714, true); // Hunters Village
break;
case 7132:
_activeChar.teleToLocation(146331, 25762, -2018, true); // Aden Castle Town
break;
case 7133:
_activeChar.teleToLocation(147928, -55273, -2734, true); // Goddard Castle Town
break;
case 7134:
_activeChar.teleToLocation(43799, -47727, -798, true); // Rune Castle Town
break;
case 7618:
_activeChar.teleToLocation(149864, -81062, -5618, true); // Ketra Orc Village
break;
case 7619:
_activeChar.teleToLocation(108275, -53785, -2524, true); // Varka Silenos Village
break;
default:
_activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
break;
}
}
catch (final Throwable e)
{
if (Config.DEBUG)
{
e.printStackTrace();
}
}
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,152 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.1.2.2.2.7 $ $Date: 2005/04/05 19:41:13 $
*/
public class ScrollOfResurrection implements IItemHandler
{
// all the items ids that this handler knows
private final static int[] _itemIds =
{
737,
3936,
3959,
6387
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
if (activeChar.isAllSkillsDisabled())
{
return;
}
final L2Character target = (L2Character) activeChar.getTarget();
boolean res = true;
if (target == null)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_CANT_FOUND));
res = false;
}
if (target != null)
{
if (!target.isDead())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
res = false;
}
else if (!(target instanceof L2PcInstance) && !(target instanceof L2PetInstance))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
res = false;
}
}
if (activeChar.isSitting())
{
res = false;
}
if (activeChar.isFestivalParticipant())
{
res = false;
activeChar.sendMessage("Resurrection inside festival is prohibited.");
}
if (activeChar.isInOlympiadMode())
{
res = false;
activeChar.sendMessage("You cannot use this item during an Olympiad match.");
}
int skillId = 0;
switch (item.getItemId())
{
case 737:
skillId = 2014; // Scroll of Resurrection
break;
case 3936:
skillId = 2049; // Blessed Scroll of Resurrection
break;
case 3959:
skillId = 2062; // L2Day - Blessed Scroll of Resurrection
break;
case 6387:
if (!(target instanceof L2PetInstance))
{
res = false;
}
skillId = 2179; // Blessed Scroll of Resurrection: For Pets
break;
}
if (res)
{
if (!activeChar.destroyItem("Consume", item.getObjectId(), 1, null, true))
{
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(skillId, 1);
if (skill != null)
{
activeChar.useMagic(skill, true, true);
}
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,313 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.1.6.4 $ $Date: 2005/04/06 18:25:18 $
*/
public class Scrolls implements IItemHandler
{
private static int[] _itemIds =
{
3926,
3927,
3928,
3929,
3930,
3931,
3932,
3933,
3934,
3935,
4218,
5593,
5594,
5595,
6037,
5703,
5803,
5804,
5805,
5806,
5807,
6652,
6655
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
L2PcInstance activeChar;
if (playable instanceof L2PcInstance)
{
activeChar = (L2PcInstance) playable;
}
else if (playable instanceof L2PetInstance)
{
activeChar = ((L2PetInstance) playable).getOwner();
}
else
{
return;
}
if (activeChar.isAllSkillsDisabled())
{
activeChar.sendPacket(new ActionFailed());
return;
}
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.getEventTeam() > 0)
{
activeChar.sendMessage("This item cannot be used in TvT Event.");
return;
}
final int itemId = item.getItemId();
if ((itemId == 5703) || ((itemId >= 5803) && (itemId <= 5807)))
{
if (((itemId == 5703) && (activeChar.getExpertiseIndex() == 0)) || // Lucky Charm (No Grade)
((itemId == 5803) && (activeChar.getExpertiseIndex() == 1)) || // Lucky Charm (D Grade)
((itemId == 5804) && (activeChar.getExpertiseIndex() == 2)) || // Lucky Charm (C Grade)
((itemId == 5805) && (activeChar.getExpertiseIndex() == 3)) || // Lucky Charm (B Grade)
((itemId == 5806) && (activeChar.getExpertiseIndex() == 4)) || // Lucky Charm (A Grade)
((itemId == 5807) && (activeChar.getExpertiseIndex() == 5))) // Lucky Charm (S Grade)
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, playable, 2168, activeChar.getExpertiseIndex() + 1, 1, 0));
useScroll(activeChar, 2168, activeChar.getExpertiseIndex() + 1);
activeChar.setCharmOfLuck(true);
}
else
{
SystemMessage sm = new SystemMessage(SystemMessage.S1_CANNOT_BE_USED);
sm.addItemName(item.getItemId());
activeChar.sendPacket(sm);
sm = null;
}
return;
}
if (itemId == 3926) // Scroll of Guidance XML:2050
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2050, 1, 1, 0));
useScroll(activeChar, 2050, 1);
}
else if (itemId == 3927) // Scroll of Death Whipser XML:2051
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2051, 1, 1, 0));
useScroll(activeChar, 2051, 1);
}
else if (itemId == 3928) // Scroll of Focus XML:2052
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2052, 1, 1, 0));
useScroll(activeChar, 2052, 1);
}
else if (itemId == 3929) // Scroll of Greater Acumen XML:2053
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2053, 1, 1, 0));
useScroll(activeChar, 2053, 1);
}
else if (itemId == 3930) // Scroll of Haste XML:2054
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2054, 1, 1, 0));
useScroll(activeChar, 2054, 1);
}
else if (itemId == 3931) // Scroll of Agility XML:2055
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2055, 1, 1, 0));
useScroll(activeChar, 2055, 1);
}
else if (itemId == 3932) // Scroll of Mystic Enpower XML:2056
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2056, 1, 1, 0));
useScroll(activeChar, 2056, 1);
}
else if (itemId == 3933) // Scroll of Might XML:2057
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2057, 1, 1, 0));
useScroll(activeChar, 2057, 1);
}
else if (itemId == 3934) // Scroll of Wind Walk XML:2058
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2058, 1, 1, 0));
useScroll(activeChar, 2058, 1);
}
else if (itemId == 3935) // Scroll of Shield XML:2059
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2059, 1, 1, 0));
useScroll(activeChar, 2059, 1);
}
else if (itemId == 4218) // Scroll of Mana Regeneration XML:2064
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, activeChar, 2064, 1, 1, 0));
useScroll(activeChar, 2064, 1);
}
else if (itemId == 6037) // Scroll of Waking XML:2170
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, playable, 2170, 1, 1, 0));
useScroll(activeChar, 2170, 1);
}
else if (itemId == 6652) // Amulet: Protection of Valakas XML:2231
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, playable, 2231, 1, 1, 0));
useScroll(activeChar, 2231, 1);
}
else if (itemId == 6655) // Amulet: Slay Valakas XML:2232
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(playable, playable, 2232, 1, 1, 0));
useScroll(activeChar, 2232, 1);
}
else if ((itemId == 5593) || (itemId == 5594) || (itemId == 5595)) // SP Scrolls
{
if (!playable.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
}
int amountSP = 0;
switch (itemId)
{
case 5593: // Low Grade
amountSP = 500;
break;
case 5594: // Medium Grade
amountSP = 5000;
break;
case 5595: // High Grade
amountSP = 100000;
break;
}
activeChar.sendPacket(new MagicSkillUse(playable, playable, 2167, 1, 1, 0));
activeChar.broadcastPacket(new MagicSkillUse(playable, playable, 2167, 1, 1, 0));
activeChar.addExpAndSp(0, amountSP);
}
}
public void useScroll(L2PcInstance activeChar, int magicId, int level)
{
final L2Skill skill = SkillTable.getInstance().getInfo(magicId, level);
if (skill != null)
{
activeChar.doCast(skill);
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,316 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.datatables.MapRegionTable;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Manor;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2RaidBossInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class Seed implements IItemHandler
{
private static int[] _itemIds =
{
5016,
5017,
5018,
5019,
5020,
5021,
5022,
5023,
5024,
5025,
5026,
5027,
5028,
5029,
5030,
5031,
5032,
5033,
5034,
5035,
5036,
5037,
5038,
5039,
5040,
5041,
5042,
5043,
5044,
5045,
5046,
5047,
5048,
5049,
5050,
5051,
5052,
5053,
5054,
5055,
5056,
5057,
5058,
5059,
5060,
5061,
5221,
5222,
5223,
5224,
5225,
5226,
5227,
5650,
5651,
5652,
5653,
5654,
5655,
5656,
5657,
5658,
5659,
5660,
5661,
5662,
5663,
5664,
5665,
5666,
5667,
5668,
5669,
5670,
5671,
5672,
5673,
5674,
5675,
5676,
5677,
5678,
5679,
5680,
5681,
5682,
5683,
5684,
5685,
5686,
5687,
5688,
5689,
5690,
5691,
5692,
5693,
5694,
5695,
5696,
5697,
5698,
5699,
5700,
5701,
5702,
6727,
6728,
6729,
6730,
6731,
6732,
6733,
6734,
6735,
6736,
6737,
6738,
6739,
6740,
6741,
6742,
6743,
6744,
6745,
6746,
6747,
6748,
6749,
6750,
6751,
6752,
6753,
6754,
6755,
6756,
6757,
6758,
6759,
6760,
6761,
6762,
6763,
6764,
6765,
6766,
6767,
6768,
6769,
6770,
6771,
6772,
6773,
6774,
6775,
6776,
6777,
6778,
7016,
7017,
7018,
7019,
7020,
7021,
7022,
7023,
7024,
7025,
7026,
7027,
7028,
7029,
7030,
7031,
7032,
7033,
7034,
7035,
7036,
7037,
7038,
7039,
7040,
7041,
7042,
7043,
7044,
7045,
7046,
7047,
7048,
7049,
7050,
7051,
7052,
7053,
7054,
7055,
7056,
7057
};
private int _seedId;
L2MonsterInstance _target;
L2PcInstance _activeChar;
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
if (CastleManorManager.getInstance().isDisabled())
{
return;
}
_activeChar = (L2PcInstance) playable;
if (!(_activeChar.getTarget() instanceof L2NpcInstance))
{
_activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
_activeChar.sendPacket(new ActionFailed());
return;
}
final L2NpcInstance target = (L2NpcInstance) _activeChar.getTarget();
if (!(target instanceof L2MonsterInstance) || (target instanceof L2ChestInstance) || (target instanceof L2GrandBossInstance) || (target instanceof L2RaidBossInstance))
{
_activeChar.sendPacket(new SystemMessage(SystemMessage.THE_TARGET_IS_UNAVAILABLE_FOR_SEEDING));
_activeChar.sendPacket(new ActionFailed());
return;
}
_target = (L2MonsterInstance) target;
if ((_target == null) || _target.isDead())
{
_activeChar.sendPacket(new SystemMessage(SystemMessage.INCORRECT_TARGET));
_activeChar.sendPacket(new ActionFailed());
return;
}
if (_target.isSeeded())
{
_activeChar.sendPacket(new ActionFailed());
return;
}
_seedId = item.getItemId();
if (areaValid(MapRegionTable.getInstance().getAreaCastle(_activeChar)))
{
_target.setSeeded(_seedId, _activeChar);
final L2Skill skill = SkillTable.getInstance().getInfo(2097, 3); // sowing skill
_activeChar.useMagic(skill, false, false);
}
else
{
_activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_SEED_MAY_NOT_BE_SOWN_HERE));
}
}
private boolean areaValid(int castleId)
{
return (L2Manor.getInstance().getCastleIdForSeed(_seedId) == castleId);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.SSQStatus;
/**
* Item Handler for Seven Signs Record
* @author Tempy
*/
public class SevenSignsRecord implements IItemHandler
{
private static int[] _itemIds =
{
5707
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
L2PcInstance activeChar;
if (playable instanceof L2PcInstance)
{
activeChar = (L2PcInstance) playable;
}
else if (playable instanceof L2PetInstance)
{
activeChar = ((L2PetInstance) playable).getOwner();
}
else
{
return;
}
final SSQStatus ssqs = new SSQStatus(activeChar, 1);
activeChar.sendPacket(ssqs);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,166 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2Attackable;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class ...
* @version $Revision: 1.2.4 $ $Date: 2005/08/14 21:31:07 $
*/
public class SoulCrystals implements IItemHandler
{
// First line is for Red Soul Crystals, second is Green and third is Blue Soul Crystals,
// ordered by ascending level, from 0 to 13...
private static int[] _itemIds =
{
4629,
4630,
4631,
4632,
4633,
4634,
4635,
4636,
4637,
4638,
4639,
5577,
5580,
5908,
4640,
4641,
4642,
4643,
4644,
4645,
4646,
4647,
4648,
4649,
4650,
5578,
5581,
5911,
4651,
4652,
4653,
4654,
4655,
4656,
4657,
4658,
4659,
4660,
4661,
5579,
5582,
5914
};
// Our main method, where everything goes on
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2MonsterInstance))
{
// Send a System Message to the caster
final SystemMessage sm = new SystemMessage(109);
activeChar.sendPacket(sm);
// Send a Server->Client packet ActionFailed to the L2PcInstance
activeChar.sendPacket(new ActionFailed());
return;
}
// you can use soul crystal only when target hp goes to < 50%
if (((L2MonsterInstance) target).getCurrentHp() > (((L2MonsterInstance) target).getMaxHp() / 2))
{
activeChar.sendPacket(new ActionFailed());
return;
}
final L2Skill skill = SkillTable.getInstance().getInfo(2096, 1);
activeChar.useMagic(skill, false, true);
// Continue execution later
final CrystalFinalizer cf = new CrystalFinalizer(activeChar, target, item.getItemId());
ThreadPoolManager.getInstance().scheduleEffect(cf, skill.getHitTime());
}
static class CrystalFinalizer implements Runnable
{
private final L2PcInstance _activeChar;
private final L2Attackable _target;
private final int _crystalId;
CrystalFinalizer(L2PcInstance activeChar, L2Object target, int crystalId)
{
_activeChar = activeChar;
_target = (L2Attackable) target;
_crystalId = crystalId;
}
@Override
public void run()
{
if (_activeChar.isDead() || _target.isDead())
{
return;
}
_activeChar.enableAllSkills();
try
{
_target.addAbsorber(_activeChar, _crystalId);
_activeChar.setTarget(_target);
}
catch (final Throwable e)
{
e.printStackTrace();
}
}
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,127 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.skills.Stats;
import com.l2jmobius.gameserver.templates.L2Item;
import com.l2jmobius.gameserver.templates.L2Weapon;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* This class ...
* @version $Revision: 1.2.4.4 $ $Date: 2005/03/27 15:30:07 $
*/
public class SoulShots implements IItemHandler
{
// All the item IDs that this handler knows.
private static int[] _itemIds =
{
5789,
1835,
1463,
1464,
1465,
1466,
1467
};
private static int[] _skillIds =
{
2039,
2150,
2151,
2152,
2153,
2154
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final int itemId = item.getItemId();
// Check if Soulshot can be used
if ((weaponInst == null) || (weaponItem.getSoulShotCount() == 0))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANNOT_USE_SOULSHOTS));
}
return;
}
// Check if Soulshot is already active
if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
{
return;
}
// Check for correct grade
final int weaponGrade = weaponItem.getCrystalType();
if (((weaponGrade == L2Item.CRYSTAL_NONE) && (itemId != 5789) && (itemId != 1835)) || ((weaponGrade == L2Item.CRYSTAL_D) && (itemId != 1463)) || ((weaponGrade == L2Item.CRYSTAL_C) && (itemId != 1464)) || ((weaponGrade == L2Item.CRYSTAL_B) && (itemId != 1465)) || ((weaponGrade == L2Item.CRYSTAL_A) && (itemId != 1466)) || ((weaponGrade == L2Item.CRYSTAL_S) && (itemId != 1467)))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.SOULSHOTS_GRADE_MISMATCH));
}
return;
}
// Consume Soulshots if player has enough of them
final int saSSCount = (int) activeChar.getStat().calcStat(Stats.SOULSHOT_COUNT, 0, null, null);
final int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
{
if (!activeChar.disableAutoShot(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.NOT_ENOUGH_SOULSHOTS));
}
return;
}
// Charge soulshot
weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_SOULSHOT);
// Send message to client
activeChar.sendPacket(new SystemMessage(SystemMessage.ENABLED_SOULSHOT));
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, _skillIds[weaponGrade], 1, 0, 0), 360000/* 600 */);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowXMasSeal;
/**
* @author devScarlet & mrTJO
*/
public class SpecialXMas implements IItemHandler
{
private static int[] _itemIds =
{
5555
};
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final int itemId = item.getItemId();
if (itemId == 5555) // Token of Love
{
final ShowXMasSeal SXS = new ShowXMasSeal(5555);
activeChar.broadcastPacket(SXS);
}
}
/**
* @see com.l2jmobius.gameserver.handler.IItemHandler#getItemIds()
*/
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,123 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2Item;
import com.l2jmobius.gameserver.templates.L2Weapon;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.5 $ $Date: 2005/03/27 15:30:07 $
*/
public class SpiritShot implements IItemHandler
{
// All the item IDs that this handler knows.
private static int[] _itemIds =
{
5790,
2509,
2510,
2511,
2512,
2513,
2514
};
private static int[] _skillIds =
{
2061,
2155,
2156,
2157,
2158,
2159
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final int itemId = item.getItemId();
// Check if Spiritshot can be used
if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANNOT_USE_SPIRITSHOTS));
}
return;
}
// Check if Spiritshot is already active
if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
{
return;
}
// Check for correct grade
final int weaponGrade = weaponItem.getCrystalType();
if (((weaponGrade == L2Item.CRYSTAL_NONE) && (itemId != 5790) && (itemId != 2509)) || ((weaponGrade == L2Item.CRYSTAL_D) && (itemId != 2510)) || ((weaponGrade == L2Item.CRYSTAL_C) && (itemId != 2511)) || ((weaponGrade == L2Item.CRYSTAL_B) && (itemId != 2512)) || ((weaponGrade == L2Item.CRYSTAL_A) && (itemId != 2513)) || ((weaponGrade == L2Item.CRYSTAL_S) && (itemId != 2514)))
{
if (!activeChar.getAutoSoulShot().contains(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.SPIRITSHOTS_GRADE_MISMATCH));
}
return;
}
// Consume Spiritshot if player has enough of them
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
{
if (!activeChar.disableAutoShot(itemId))
{
activeChar.sendPacket(new SystemMessage(SystemMessage.NOT_ENOUGH_SPIRITSHOTS));
}
return;
}
// Charge Spiritshot
weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_SPIRITSHOT);
// Send message to client
activeChar.sendPacket(new SystemMessage(SystemMessage.ENABLED_SPIRITSHOT));
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, _skillIds[weaponGrade], 1, 0, 0), 360000/* 600 */);
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,337 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.NpcTable;
import com.l2jmobius.gameserver.datatables.SkillTable;
import com.l2jmobius.gameserver.datatables.SummonItemsData;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2SummonItem;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillLaunched;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.PetItemList;
import com.l2jmobius.gameserver.network.serverpackets.SetupGauge;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.L2NpcTemplate;
/**
* @author FBIagent
*/
public class SummonItems implements IItemHandler
{
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
if (!activeChar.getFloodProtectors().getItemPetSummon().tryPerformAction("summon items"))
{
return;
}
if (activeChar.isSitting())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.CANT_MOVE_SITTING));
return;
}
if (activeChar.inObserverMode())
{
return;
}
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.getEventTeam() > 0)
{
activeChar.sendMessage("You may not summon a pet in TvT Event.");
return;
}
if (activeChar.isAllSkillsDisabled())
{
return;
}
final L2SummonItem sitem = SummonItemsData.getInstance().getSummonItem(item.getItemId());
if (((activeChar.getPet() != null) || activeChar.isMounted()) && sitem.isPetSummon())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_ALREADY_HAVE_A_PET));
return;
}
if (activeChar.isAttackingNow() || activeChar.isRooted())
{
activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_CANNOT_SUMMON_IN_COMBAT));
return;
}
final int npcID = sitem.getNpcId();
if (npcID == 0)
{
return;
}
final L2NpcTemplate npcTemplate = NpcTable.getInstance().getTemplate(npcID);
if (npcTemplate == null)
{
return;
}
activeChar.stopMove(null);
switch (sitem.getType())
{
case 0: // static summons (like christmas tree)
try
{
final L2Spawn spawn = new L2Spawn(npcTemplate);
// if (spawn == null)
// {
// return;
// }
spawn.setId(IdFactory.getInstance().getNextId());
spawn.setLocx(activeChar.getX());
spawn.setLocy(activeChar.getY());
spawn.setLocz(activeChar.getZ());
L2World.getInstance().storeObject(spawn.spawnOne());
activeChar.destroyItem("Summon", item.getObjectId(), 1, null, false);
activeChar.sendMessage("Created " + npcTemplate.name + " at x: " + spawn.getLocx() + " y: " + spawn.getLocy() + " z: " + spawn.getLocz());
}
catch (final Exception e)
{
activeChar.sendMessage("Target is not in game.");
}
break;
case 1: // pet summons
final L2Object oldtarget = activeChar.getTarget();
activeChar.setTarget(activeChar);
final L2Skill skill = SkillTable.getInstance().getInfo(2046, 1);
if (skill == null)
{
return;
}
activeChar.broadcastPacket(new MagicSkillUse(activeChar, skill.getId(), 1, skill.getHitTime(), 0));
activeChar.setTarget(oldtarget);
activeChar.sendPacket(new SetupGauge(0, 5000));
activeChar.sendPacket(new SystemMessage(SystemMessage.SUMMON_A_PET));
activeChar.disableAllSkills();
final PetSummonFinalizer psf = new PetSummonFinalizer(activeChar, npcTemplate, item);
activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleEffect(psf, skill.getHitTime()));
activeChar.setSkillCastEndTime(10 + GameTimeController.getGameTicks() + (skill.getHitTime() / GameTimeController.MILLIS_IN_TICK));
break;
case 2: // wyvern
activeChar.mount(sitem.getNpcId(), item.getObjectId(), true);
break;
}
}
static class PetSummonFeedWait implements Runnable
{
private final L2PcInstance _activeChar;
private final L2PetInstance _petSummon;
PetSummonFeedWait(L2PcInstance activeChar, L2PetInstance petSummon)
{
_activeChar = activeChar;
_petSummon = petSummon;
}
@Override
public void run()
{
try
{
if (_petSummon.getCurrentFed() <= 0)
{
_petSummon.unSummon(_activeChar);
}
else
{
_petSummon.startFeed();
}
}
catch (final Throwable e)
{
}
}
}
static class PetSummonFinalizer implements Runnable
{
private final L2PcInstance _activeChar;
private final L2ItemInstance _item;
private final L2NpcTemplate _npcTemplate;
PetSummonFinalizer(L2PcInstance activeChar, L2NpcTemplate npcTemplate, L2ItemInstance item)
{
_activeChar = activeChar;
_npcTemplate = npcTemplate;
_item = item;
}
@Override
public void run()
{
try
{
_activeChar.sendPacket(new MagicSkillLaunched(_activeChar, 2046, 1));
_activeChar.enableAllSkills();
final L2PetInstance petSummon = L2PetInstance.spawnPet(_npcTemplate, _activeChar, _item);
if (petSummon == null)
{
return;
}
petSummon.setTitle(_activeChar.getName());
if (!petSummon.isRespawned())
{
petSummon.setCurrentHp(petSummon.getMaxHp());
petSummon.setCurrentMp(petSummon.getMaxMp());
petSummon.getStat().setExp(petSummon.getExpForThisLevel());
petSummon.setCurrentFed(petSummon.getMaxFed());
}
petSummon.setRunning();
if (!petSummon.isRespawned())
{
petSummon.store();
}
_activeChar.setPet(petSummon);
L2World.getInstance().storeObject(petSummon);
petSummon.spawnMe(_activeChar.getX() + 50, _activeChar.getY() + 100, _activeChar.getZ());
petSummon.startFeed();
_item.setEnchantLevel(petSummon.getLevel());
if (petSummon.getCurrentFed() <= 0)
{
ThreadPoolManager.getInstance().scheduleGeneral(new PetSummonFeedWait(_activeChar, petSummon), 60000);
}
else
{
petSummon.startFeed();
}
petSummon.setFollowStatus(true);
petSummon.setShowSummonAnimation(false);
final int weaponId = petSummon.getWeapon();
final int armorId = petSummon.getArmor();
final int jewelId = petSummon.getJewel();
if ((weaponId > 0) && (petSummon.getOwner().getInventory().getItemByItemId(weaponId) != null))
{
final L2ItemInstance item = petSummon.getOwner().getInventory().getItemByItemId(weaponId);
final L2ItemInstance newItem = petSummon.getOwner().transferItem("Transfer", item.getObjectId(), 1, petSummon.getInventory(), petSummon);
if (newItem == null)
{
petSummon.setWeapon(0);
}
else
{
petSummon.getInventory().equipItem(newItem);
}
}
else
{
petSummon.setWeapon(0);
}
if ((armorId > 0) && (petSummon.getOwner().getInventory().getItemByItemId(armorId) != null))
{
final L2ItemInstance item = petSummon.getOwner().getInventory().getItemByItemId(armorId);
final L2ItemInstance newItem = petSummon.getOwner().transferItem("Transfer", item.getObjectId(), 1, petSummon.getInventory(), petSummon);
if (newItem == null)
{
petSummon.setArmor(0);
}
else
{
petSummon.getInventory().equipItem(newItem);
}
}
else
{
petSummon.setArmor(0);
}
if ((jewelId > 0) && (petSummon.getOwner().getInventory().getItemByItemId(jewelId) != null))
{
final L2ItemInstance item = petSummon.getOwner().getInventory().getItemByItemId(jewelId);
final L2ItemInstance newItem = petSummon.getOwner().transferItem("Transfer", item.getObjectId(), 1, petSummon.getInventory(), petSummon);
if (newItem == null)
{
petSummon.setJewel(0);
}
else
{
petSummon.getInventory().equipItem(newItem);
}
}
else
{
petSummon.setJewel(0);
}
petSummon.getOwner().sendPacket(new PetItemList(petSummon));
petSummon.broadcastStatusUpdate();
}
catch (final Throwable e)
{
}
}
}
@Override
public int[] getItemIds()
{
return SummonItemsData.getInstance().itemIDs();
}
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.itemhandlers;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowMiniMap;
/**
* This class ...
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:07 $
*/
public class WorldMap implements IItemHandler
{
// all the items ids that this handler knowns
private static int[] _itemIds =
{
1665,
1863
};
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.handler.IItemHandler#useItem(com.l2jmobius.gameserver.model.L2PcInstance, com.l2jmobius.gameserver.model.L2ItemInstance)
*/
@Override
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
{
return;
}
final L2PcInstance activeChar = (L2PcInstance) playable;
activeChar.sendPacket(new ShowMiniMap(item.getItemId()));
return;
}
@Override
public int[] getItemIds()
{
return _itemIds;
}
}

View File

@@ -0,0 +1,104 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.skillhandlers;
import com.l2jmobius.gameserver.handler.ISkillHandler;
import com.l2jmobius.gameserver.handler.SkillHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
/**
* This class ...
* @author earendil
* @version $Revision: 1.1.2.2.2.4 $ $Date: 2005/04/06 16:13:48 $
*/
public class BalanceLife implements ISkillHandler
{
private static SkillType[] _skillIds =
{
SkillType.BALANCE_LIFE
};
@Override
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets, boolean crit)
{
// check for other effects
try
{
final ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(SkillType.BUFF);
if (handler != null)
{
handler.useSkill(activeChar, skill, targets, crit);
}
}
catch (final Exception e)
{
}
double fullHP = 0;
double currentHPs = 0;
for (final L2Object target2 : targets)
{
final L2Character target = (L2Character) target2;
// We should not heal if char is dead
if ((target == null) || target.isDead())
{
continue;
}
fullHP += target.getMaxHp();
currentHPs += target.getCurrentHp();
}
final double percentHP = currentHPs / fullHP;
for (final L2Object target2 : targets)
{
final L2Character target = (L2Character) target2;
final double newHP = target.getMaxHp() * percentHP;
final double totalHeal = newHP - target.getCurrentHp();
target.setCurrentHp(newHP);
if (totalHeal > 0)
{
target.setLastHealAmount((int) totalHeal);
}
final StatusUpdate su = new StatusUpdate(target.getObjectId());
su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp());
target.sendPacket(su);
target.sendMessage("HP of the party has been balanced.");
}
}
@Override
public SkillType[] getSkillIds()
{
return _skillIds;
}
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.skillhandlers;
import com.l2jmobius.gameserver.handler.ISkillHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author _drunk_ TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
*/
public class BeastFeed implements ISkillHandler
{
protected SkillType[] _skillIds =
{
SkillType.BEAST_FEED
};
@Override
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets, boolean crit)
{
if (!(activeChar instanceof L2PcInstance))
{
return;
}
final L2Object[] targetList = skill.getTargetList(activeChar);
if (targetList == null)
{
return;
}
// This is just a dummy skill handler for the golden food and crystal food skills,
// since the AI responce onSkillUse handles the rest.
}
@Override
public SkillType[] getSkillIds()
{
return _skillIds;
}
}

View File

@@ -0,0 +1,150 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.handler.skillhandlers;
import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.handler.ISkillHandler;
import com.l2jmobius.gameserver.model.L2Character;
import com.l2jmobius.gameserver.model.L2Effect;
import com.l2jmobius.gameserver.model.L2ItemInstance;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Skill;
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.skills.Formulas;
/**
* @author Steuf
*/
public class Blow implements ISkillHandler
{
private static final SkillType[] SKILL_IDS =
{
SkillType.BLOW
};
public final static byte FRONT = 50;
public final static byte SIDE = 60;
public final static byte BEHIND = 70;
@Override
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets, boolean success)
{
if (activeChar.isAlikeDead())
{
return;
}
for (int index = 0; index < targets.length; index++)
{
final L2Character target = (L2Character) targets[index];
if (target.isAlikeDead())
{
continue;
}
// For the first target, it's already calculated
if (index != 0)
{
byte _successChance = SIDE;
if (activeChar.isBehindTarget())
{
_successChance = BEHIND;
}
else if (activeChar.isInFrontOfTarget())
{
_successChance = FRONT;
}
// If skill requires critical or skill requires behind,
// calculate chance based on DEX, Position and on self BUFF
success = true;
if ((skill.getCondition() & L2Skill.COND_BEHIND) != 0)
{
success = (_successChance == BEHIND);
}
if ((skill.getCondition() & L2Skill.COND_CRIT) != 0)
{
success = (success && Formulas.getInstance().calcBlow(activeChar, target, _successChance));
}
}
if (success)
{
final L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
final boolean soul = ((weapon != null) && (weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT));
final boolean shld = Formulas.getInstance().calcShldUse(activeChar, target);
final double damage = (int) Formulas.getInstance().calcBlowDamage(activeChar, target, skill, shld, soul);
if (damage > 0)
{
// Manage attack or cast break of the target (calculating rate, sending message...)
if (Formulas.getInstance().calcAtkBreak(target, damage))
{
target.breakAttack();
target.breakCast();
}
}
target.reduceCurrentHp(damage, activeChar);
if (activeChar instanceof L2PcInstance)
{
if (((L2PcInstance) activeChar).isInOlympiadMode() && (target instanceof L2PcInstance))
{
((L2PcInstance) activeChar).dmgDealt += damage;
}
activeChar.sendPacket(new SystemMessage(SystemMessage.CRITICAL_HIT));
final SystemMessage sm = new SystemMessage(SystemMessage.YOU_DID_S1_DMG);
sm.addNumber((int) damage);
activeChar.sendPacket(sm);
}
}
if (skill.getId() == 344)
{
Formulas.getInstance().calcLethalStrike(activeChar, target, skill.getMagicLevel());
}
final L2Effect effect = activeChar.getFirstEffect(skill.getId());
// Self Effect
if ((effect != null) && effect.isSelfEffect())
{
effect.exit();
}
skill.getEffectsSelf(activeChar);
// notify the AI that it is attacked
target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
}
}
@Override
public SkillType[] getSkillIds()
{
return SKILL_IDS;
}
}

Some files were not shown because too many files have changed in this diff Show More