Project update.

This commit is contained in:
MobiusDev
2015-12-31 23:53:41 +00:00
parent e0d681a17e
commit ad2bcd79be
4084 changed files with 83696 additions and 86998 deletions

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;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.enums.InstanceType;
/**
* @author UnAfraid
*/
public class ActionHandler implements IHandler<IActionHandler, InstanceType>
{
private final Map<InstanceType, IActionHandler> _actions;
public static ActionHandler getInstance()
{
return SingletonHolder._instance;
}
protected ActionHandler()
{
_actions = new HashMap<>();
}
@Override
public void registerHandler(IActionHandler handler)
{
_actions.put(handler.getInstanceType(), handler);
}
@Override
public synchronized void removeHandler(IActionHandler handler)
{
_actions.remove(handler.getInstanceType());
}
@Override
public IActionHandler getHandler(InstanceType iType)
{
IActionHandler result = null;
for (InstanceType t = iType; t != null; t = t.getParent())
{
result = _actions.get(t);
if (result != null)
{
break;
}
}
return result;
}
@Override
public int size()
{
return _actions.size();
}
private static class SingletonHolder
{
protected static final ActionHandler _instance = new ActionHandler();
}
}

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;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.enums.InstanceType;
/**
* @author UnAfraid
*/
public class ActionShiftHandler implements IHandler<IActionShiftHandler, InstanceType>
{
private final Map<InstanceType, IActionShiftHandler> _actionsShift;
protected ActionShiftHandler()
{
_actionsShift = new HashMap<>();
}
@Override
public void registerHandler(IActionShiftHandler handler)
{
_actionsShift.put(handler.getInstanceType(), handler);
}
@Override
public synchronized void removeHandler(IActionShiftHandler handler)
{
_actionsShift.remove(handler.getInstanceType());
}
@Override
public IActionShiftHandler getHandler(InstanceType iType)
{
IActionShiftHandler result = null;
for (InstanceType t = iType; t != null; t = t.getParent())
{
result = _actionsShift.get(t);
if (result != null)
{
break;
}
}
return result;
}
@Override
public int size()
{
return _actionsShift.size();
}
public static ActionShiftHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ActionShiftHandler _instance = new ActionShiftHandler();
}
}

View File

@ -0,0 +1,80 @@
/*
* 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.HashMap;
import java.util.Map;
/**
* @author UnAfraid
*/
public class AdminCommandHandler implements IHandler<IAdminCommandHandler, String>
{
private final Map<String, IAdminCommandHandler> _datatable;
protected AdminCommandHandler()
{
_datatable = new HashMap<>();
}
@Override
public void registerHandler(IAdminCommandHandler handler)
{
final String[] ids = handler.getAdminCommandList();
for (String id : ids)
{
_datatable.put(id, handler);
}
}
@Override
public synchronized void removeHandler(IAdminCommandHandler handler)
{
final String[] ids = handler.getAdminCommandList();
for (String id : ids)
{
_datatable.remove(id);
}
}
@Override
public IAdminCommandHandler getHandler(String adminCommand)
{
String command = adminCommand;
if (adminCommand.contains(" "))
{
command = adminCommand.substring(0, adminCommand.indexOf(" "));
}
return _datatable.get(command);
}
@Override
public int size()
{
return _datatable.size();
}
public static AdminCommandHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final AdminCommandHandler _instance = new AdminCommandHandler();
}
}

View File

@ -0,0 +1,77 @@
/*
* 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.HashMap;
import java.util.Map;
/**
* @author nBd, UnAfraid
*/
public class BypassHandler implements IHandler<IBypassHandler, String>
{
private final Map<String, IBypassHandler> _datatable;
protected BypassHandler()
{
_datatable = new HashMap<>();
}
@Override
public void registerHandler(IBypassHandler handler)
{
for (String element : handler.getBypassList())
{
_datatable.put(element.toLowerCase(), handler);
}
}
@Override
public synchronized void removeHandler(IBypassHandler handler)
{
for (String element : handler.getBypassList())
{
_datatable.remove(element.toLowerCase());
}
}
@Override
public IBypassHandler getHandler(String command)
{
if (command.contains(" "))
{
command = command.substring(0, command.indexOf(" "));
}
return _datatable.get(command.toLowerCase());
}
@Override
public int size()
{
return _datatable.size();
}
public static BypassHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final BypassHandler _instance = new BypassHandler();
}
}

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.EnumMap;
import java.util.Map;
import com.l2jmobius.gameserver.enums.ChatType;
/**
* This class handles all chat handlers
* @author durgus, UnAfraid
*/
public class ChatHandler implements IHandler<IChatHandler, ChatType>
{
private final Map<ChatType, IChatHandler> _datatable = new EnumMap<>(ChatType.class);
/**
* Singleton constructor
*/
protected ChatHandler()
{
}
/**
* Register a new chat handler
* @param handler
*/
@Override
public void registerHandler(IChatHandler handler)
{
for (ChatType type : handler.getChatTypeList())
{
_datatable.put(type, handler);
}
}
@Override
public synchronized void removeHandler(IChatHandler handler)
{
for (ChatType type : handler.getChatTypeList())
{
_datatable.remove(type);
}
}
/**
* Get the chat handler for the given chat type
* @param chatType
* @return
*/
@Override
public IChatHandler getHandler(ChatType chatType)
{
return _datatable.get(chatType);
}
/**
* Returns the size
* @return
*/
@Override
public int size()
{
return _datatable.size();
}
public static ChatHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ChatHandler _instance = new ChatHandler();
}
}

View File

@ -0,0 +1,233 @@
/*
* 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.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.util.Util;
/**
* Community Board handler.
* @author Zoey76
*/
public final class CommunityBoardHandler implements IHandler<IParseBoardHandler, String>
{
private static final Logger LOG = Logger.getLogger(CommunityBoardHandler.class.getName());
/** The registered handlers. */
private final Map<String, IParseBoardHandler> _datatable = new HashMap<>();
/** The bypasses used by the players. */
private final Map<Integer, String> _bypasses = new ConcurrentHashMap<>();
protected CommunityBoardHandler()
{
// Prevent external initialization.
}
@Override
public void registerHandler(IParseBoardHandler handler)
{
for (String cmd : handler.getCommunityBoardCommands())
{
_datatable.put(cmd.toLowerCase(), handler);
}
}
@Override
public synchronized void removeHandler(IParseBoardHandler handler)
{
for (String cmd : handler.getCommunityBoardCommands())
{
_datatable.remove(cmd.toLowerCase());
}
}
@Override
public IParseBoardHandler getHandler(String cmd)
{
for (IParseBoardHandler cb : _datatable.values())
{
for (String command : cb.getCommunityBoardCommands())
{
if (cmd.toLowerCase().startsWith(command.toLowerCase()))
{
return cb;
}
}
}
return null;
}
@Override
public int size()
{
return _datatable.size();
}
/**
* Verifies if the string is a registered community board command.
* @param cmd the command to verify
* @return {@code true} if the command has been registered, {@code false} otherwise
*/
public boolean isCommunityBoardCommand(String cmd)
{
return getHandler(cmd) != null;
}
/**
* Parses a community board command.
* @param command the command
* @param player the player
*/
public void handleParseCommand(String command, L2PcInstance player)
{
if (player == null)
{
return;
}
if (!Config.ENABLE_COMMUNITY_BOARD)
{
player.sendPacket(SystemMessageId.THE_COMMUNITY_SERVER_IS_CURRENTLY_OFFLINE);
return;
}
final IParseBoardHandler cb = getHandler(command);
if (cb == null)
{
LOG.warning(CommunityBoardHandler.class.getSimpleName() + ": Couldn't find parse handler for command " + command + "!");
return;
}
cb.parseCommunityBoardCommand(command, player);
}
/**
* Writes a command into the client.
* @param player the player
* @param url the command URL
* @param arg1 the first argument
* @param arg2 the second argument
* @param arg3 the third argument
* @param arg4 the fourth argument
* @param arg5 the fifth argument
*/
public void handleWriteCommand(L2PcInstance player, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
{
if (player == null)
{
return;
}
if (!Config.ENABLE_COMMUNITY_BOARD)
{
player.sendPacket(SystemMessageId.THE_COMMUNITY_SERVER_IS_CURRENTLY_OFFLINE);
return;
}
String cmd = "";
switch (url)
{
case "Topic":
{
cmd = "_bbstop";
break;
}
case "Post":
{
cmd = "_bbspos"; // TODO: Implement.
break;
}
case "Region":
{
cmd = "_bbsloc";
break;
}
case "Notice":
{
cmd = "_bbsclan";
break;
}
default:
{
separateAndSend("<html><body><br><br><center>The command: " + url + " is not implemented yet.</center><br><br></body></html>", player);
return;
}
}
final IParseBoardHandler cb = getHandler(cmd);
if (cb == null)
{
LOG.warning(CommunityBoardHandler.class.getSimpleName() + ": Couldn't find write handler for command " + cmd + "!");
return;
}
if (!(cb instanceof IWriteBoardHandler))
{
LOG.warning(CommunityBoardHandler.class.getSimpleName() + ": " + cb.getClass().getSimpleName() + " doesn't implement write!");
return;
}
((IWriteBoardHandler) cb).writeCommunityBoardCommand(player, arg1, arg2, arg3, arg4, arg5);
}
/**
* Sets the last bypass used by the player.
* @param player the player
* @param title the title
* @param bypass the bypass
*/
public void addBypass(L2PcInstance player, String title, String bypass)
{
_bypasses.put(player.getObjectId(), title + "&" + bypass);
}
/**
* Removes the last bypass used by the player.
* @param player the player
* @return the last bypass used
*/
public String removeBypass(L2PcInstance player)
{
return _bypasses.remove(player.getObjectId());
}
/**
* Separates and send an HTML into multiple packets, to display into the community board.<br>
* The limit is 16383 characters.
* @param html the HTML to send
* @param player the player
*/
public static void separateAndSend(String html, L2PcInstance player)
{
Util.sendCBHtml(player, html);
}
public static CommunityBoardHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final CommunityBoardHandler _instance = new CommunityBoardHandler();
}
}

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;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.scripting.L2ScriptEngineManager;
/**
* @author BiggBoss, UnAfraid
*/
public final class EffectHandler implements IHandler<Class<? extends AbstractEffect>, String>
{
private final Map<String, Class<? extends AbstractEffect>> _handlers;
protected EffectHandler()
{
_handlers = new HashMap<>();
}
@Override
public void registerHandler(Class<? extends AbstractEffect> handler)
{
_handlers.put(handler.getSimpleName(), handler);
}
@Override
public synchronized void removeHandler(Class<? extends AbstractEffect> handler)
{
_handlers.remove(handler.getSimpleName());
}
@Override
public Class<? extends AbstractEffect> getHandler(String name)
{
return _handlers.get(name);
}
@Override
public int size()
{
return _handlers.size();
}
public void executeScript()
{
try
{
final File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, "handlers/EffectMasterHandler.java");
L2ScriptEngineManager.getInstance().executeScript(file);
}
catch (Exception e)
{
throw new Error("Problems while running EffectMansterHandler", e);
}
}
private static final class SingletonHolder
{
protected static final EffectHandler _instance = new EffectHandler();
}
public static EffectHandler getInstance()
{
return SingletonHolder._instance;
}
}

View File

@ -0,0 +1,32 @@
/*
* 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.logging.Logger;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public interface IActionHandler
{
public static Logger _log = Logger.getLogger(IActionHandler.class.getName());
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact);
public InstanceType getInstanceType();
}

View File

@ -0,0 +1,32 @@
/*
* 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.logging.Logger;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public interface IActionShiftHandler
{
public static Logger _log = Logger.getLogger(IActionShiftHandler.class.getName());
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact);
public InstanceType getInstanceType();
}

View File

@ -0,0 +1,36 @@
/*
* 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;
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 java.util.logging.Logger;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author nBd
*/
public interface IBypassHandler
{
public static Logger _log = Logger.getLogger(IBypassHandler.class.getName());
/**
* This is the worker method that is called when someone uses an bypass command.
* @param command
* @param activeChar
* @param bypassOrigin
* @return success
*/
public boolean useBypass(String command, L2PcInstance activeChar, L2Character bypassOrigin);
/**
* This method is called at initialization to register all bypasses automatically.
* @return all known bypasses
*/
public String[] getBypassList();
}

View File

@ -0,0 +1,42 @@
/*
* 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.enums.ChatType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* Interface for chat handlers
* @author durgus
*/
public interface IChatHandler
{
/**
* Handles a specific type of chat messages
* @param type
* @param activeChar
* @param target
* @param text
*/
public void handleChat(ChatType type, L2PcInstance activeChar, String target, String text);
/**
* Returns a list of all chat types registered to this handler
* @return
*/
public ChatType[] getChatTypeList();
}

View File

@ -0,0 +1,33 @@
/*
* 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;
/**
* @author UnAfraid
* @param <K>
* @param <V>
*/
public interface IHandler<K, V>
{
public void registerHandler(K handler);
public void removeHandler(K handler);
public K getHandler(V val);
public int size();
}

View File

@ -0,0 +1,39 @@
/*
* 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.logging.Logger;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* Mother class of all Item Handlers.
*/
public interface IItemHandler
{
public static final Logger _log = Logger.getLogger(IItemHandler.class.getName());
/**
* Launch task associated to the item.
* @param playable the non-NPC character using the item
* @param item L2ItemInstance designating the item to use
* @param forceUse ctrl hold on item use
* @return {@code true} if the item all conditions are met and the item is used, {@code false} otherwise.
*/
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse);
}

View File

@ -0,0 +1,44 @@
/*
* 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.logging.Logger;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* Community Board interface.
* @author Zoey76
*/
public interface IParseBoardHandler
{
public static final Logger LOG = Logger.getLogger(IParseBoardHandler.class.getName());
/**
* Parses a community board command.
* @param command the command
* @param player the player
* @return
*/
public boolean parseCommunityBoardCommand(String command, L2PcInstance player);
/**
* Gets the community board commands.
* @return the community board commands
*/
public String[] getCommunityBoardCommands();
}

View File

@ -0,0 +1,36 @@
/*
* 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.logging.Logger;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
/**
* @author UnAfraid
*/
public interface IPunishmentHandler
{
static final Logger _log = Logger.getLogger(IPunishmentHandler.class.getName());
public void onStart(PunishmentTask task);
public void onEnd(PunishmentTask task);
public PunishmentType getType();
}

View File

@ -0,0 +1,34 @@
/*
* 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.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public interface ITargetTypeHandler
{
static final L2Object[] EMPTY_TARGET_LIST = new L2Object[0];
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target);
public Enum<L2TargetType> getTargetType();
}

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 java.io.PrintWriter;
import java.net.Socket;
import java.util.logging.Logger;
/**
* @author UnAfraid
*/
public interface ITelnetHandler
{
public static Logger _log = Logger.getLogger(ITelnetHandler.class.getName());
/**
* this is the worker method that is called when someone uses an bypass command
* @param command
* @param _print
* @param _cSocket
* @param __uptime
* @return success
*/
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int __uptime);
/**
* this method is called at initialization to register all bypasses automatically
* @return all known bypasses
*/
public String[] getCommandList();
}

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 java.util.logging.Logger;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public interface IUserCommandHandler
{
public static Logger _log = Logger.getLogger(IUserCommandHandler.class.getName());
/**
* 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 java.util.logging.Logger;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public interface IVoicedCommandHandler
{
public static Logger _log = Logger.getLogger(IVoicedCommandHandler.class.getName());
/**
* this is the worker method that is called when someone uses an admin command.
* @param activeChar
* @param command
* @param params
* @return command success
*/
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
/**
* 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,38 @@
/*
* 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;
/**
* Community Board interface.
* @author Zoey76
*/
public interface IWriteBoardHandler extends IParseBoardHandler
{
/**
* Writes a community board command into the client.
* @param player the player
* @param arg1 the first argument
* @param arg2 the second argument
* @param arg3 the third argument
* @param arg4 the fourth argument
* @param arg5 the fifth argument
* @return
*/
public boolean writeCommunityBoardCommand(L2PcInstance player, String arg1, String arg2, String arg3, String arg4, String arg5);
}

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;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.model.items.L2EtcItem;
/**
* This class manages handlers of items
* @author UnAfraid
*/
public class ItemHandler implements IHandler<IItemHandler, L2EtcItem>
{
private final Map<String, IItemHandler> _datatable;
/**
* Constructor of ItemHandler
*/
protected ItemHandler()
{
_datatable = new HashMap<>();
}
/**
* 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;String ; 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)
*/
@Override
public void registerHandler(IItemHandler handler)
{
_datatable.put(handler.getClass().getSimpleName(), handler);
}
@Override
public synchronized void removeHandler(IItemHandler handler)
{
_datatable.remove(handler.getClass().getSimpleName());
}
/**
* Returns the handler of the item
* @param item
* @return IItemHandler
*/
@Override
public IItemHandler getHandler(L2EtcItem item)
{
if ((item == null) || (item.getHandlerName() == null))
{
return null;
}
return _datatable.get(item.getHandlerName());
}
/**
* Returns the number of elements contained in datatable
* @return int : Size of the datatable
*/
@Override
public int size()
{
return _datatable.size();
}
/**
* Create ItemHandler if doesn't exist and returns ItemHandler
* @return ItemHandler
*/
public static ItemHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemHandler _instance = new ItemHandler();
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
/**
* This class manages handlers of punishments.
* @author UnAfraid
*/
public class PunishmentHandler implements IHandler<IPunishmentHandler, PunishmentType>
{
private final Map<PunishmentType, IPunishmentHandler> _handlers = new HashMap<>();
protected PunishmentHandler()
{
}
@Override
public void registerHandler(IPunishmentHandler handler)
{
_handlers.put(handler.getType(), handler);
}
@Override
public synchronized void removeHandler(IPunishmentHandler handler)
{
_handlers.remove(handler.getType());
}
@Override
public IPunishmentHandler getHandler(PunishmentType val)
{
return _handlers.get(val);
}
@Override
public int size()
{
return _handlers.size();
}
public static PunishmentHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final PunishmentHandler _instance = new PunishmentHandler();
}
}

View File

@ -0,0 +1,69 @@
/*
* 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.HashMap;
import java.util.Map;
import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
/**
* @author UnAfraid
*/
public class TargetHandler implements IHandler<ITargetTypeHandler, Enum<L2TargetType>>
{
private final Map<Enum<L2TargetType>, ITargetTypeHandler> _datatable;
protected TargetHandler()
{
_datatable = new HashMap<>();
}
@Override
public void registerHandler(ITargetTypeHandler handler)
{
_datatable.put(handler.getTargetType(), handler);
}
@Override
public synchronized void removeHandler(ITargetTypeHandler handler)
{
_datatable.remove(handler.getTargetType());
}
@Override
public ITargetTypeHandler getHandler(Enum<L2TargetType> targetType)
{
return _datatable.get(targetType);
}
@Override
public int size()
{
return _datatable.size();
}
public static TargetHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final TargetHandler _instance = new TargetHandler();
}
}

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;
import java.util.HashMap;
import java.util.Map;
/**
* @author UnAfraid
*/
public class TelnetHandler implements IHandler<ITelnetHandler, String>
{
private final Map<String, ITelnetHandler> _telnetHandlers;
protected TelnetHandler()
{
_telnetHandlers = new HashMap<>();
}
@Override
public void registerHandler(ITelnetHandler handler)
{
for (String element : handler.getCommandList())
{
_telnetHandlers.put(element.toLowerCase(), handler);
}
}
@Override
public synchronized void removeHandler(ITelnetHandler handler)
{
for (String element : handler.getCommandList())
{
_telnetHandlers.remove(element.toLowerCase());
}
}
@Override
public ITelnetHandler getHandler(String command)
{
if (command.contains(" "))
{
command = command.substring(0, command.indexOf(" "));
}
return _telnetHandlers.get(command.toLowerCase());
}
@Override
public int size()
{
return _telnetHandlers.size();
}
public static TelnetHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final TelnetHandler _instance = new TelnetHandler();
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.HashMap;
import java.util.Map;
/**
* @author UnAfraid
*/
public class UserCommandHandler implements IHandler<IUserCommandHandler, Integer>
{
private final Map<Integer, IUserCommandHandler> _datatable;
protected UserCommandHandler()
{
_datatable = new HashMap<>();
}
@Override
public void registerHandler(IUserCommandHandler handler)
{
final int[] ids = handler.getUserCommandList();
for (int id : ids)
{
_datatable.put(id, handler);
}
}
@Override
public synchronized void removeHandler(IUserCommandHandler handler)
{
final int[] ids = handler.getUserCommandList();
for (int id : ids)
{
_datatable.remove(id);
}
}
@Override
public IUserCommandHandler getHandler(Integer userCommand)
{
return _datatable.get(userCommand);
}
@Override
public int size()
{
return _datatable.size();
}
public static UserCommandHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final UserCommandHandler _instance = new UserCommandHandler();
}
}

View File

@ -0,0 +1,80 @@
/*
* 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.HashMap;
import java.util.Map;
/**
* @author UnAfraid
*/
public class VoicedCommandHandler implements IHandler<IVoicedCommandHandler, String>
{
private final Map<String, IVoicedCommandHandler> _datatable;
protected VoicedCommandHandler()
{
_datatable = new HashMap<>();
}
@Override
public void registerHandler(IVoicedCommandHandler handler)
{
final String[] ids = handler.getVoicedCommandList();
for (String id : ids)
{
_datatable.put(id, handler);
}
}
@Override
public synchronized void removeHandler(IVoicedCommandHandler handler)
{
final String[] ids = handler.getVoicedCommandList();
for (String id : ids)
{
_datatable.remove(id);
}
}
@Override
public IVoicedCommandHandler getHandler(String voicedCommand)
{
String command = voicedCommand;
if (voicedCommand.contains(" "))
{
command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
}
return _datatable.get(command);
}
@Override
public int size()
{
return _datatable.size();
}
public static VoicedCommandHandler getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
}
}