Classic branch.
This commit is contained in:
@@ -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;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.DailyMissionStatus;
|
||||
import com.l2jmobius.gameserver.model.DailyMissionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.ListenersContainer;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public abstract class AbstractDailyMissionHandler extends ListenersContainer
|
||||
{
|
||||
protected Logger LOGGER = Logger.getLogger(getClass().getName());
|
||||
|
||||
private final Map<Integer, DailyMissionPlayerEntry> _entries = new ConcurrentHashMap<>();
|
||||
private final DailyMissionDataHolder _holder;
|
||||
|
||||
protected AbstractDailyMissionHandler(DailyMissionDataHolder holder)
|
||||
{
|
||||
_holder = holder;
|
||||
init();
|
||||
}
|
||||
|
||||
public DailyMissionDataHolder getHolder()
|
||||
{
|
||||
return _holder;
|
||||
}
|
||||
|
||||
public abstract boolean isAvailable(L2PcInstance player);
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public int getStatus(L2PcInstance player)
|
||||
{
|
||||
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
|
||||
return entry != null ? entry.getStatus().getClientId() : DailyMissionStatus.NOT_AVAILABLE.getClientId();
|
||||
}
|
||||
|
||||
public int getProgress(L2PcInstance player)
|
||||
{
|
||||
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
|
||||
return entry != null ? entry.getProgress() : 0;
|
||||
}
|
||||
|
||||
public synchronized void reset()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_daily_rewards WHERE rewardId = ? AND status = ?"))
|
||||
{
|
||||
ps.setInt(1, _holder.getId());
|
||||
ps.setInt(2, DailyMissionStatus.COMPLETED.getClientId());
|
||||
ps.execute();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Error while clearing data for: " + getClass().getSimpleName(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_entries.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean requestReward(L2PcInstance player)
|
||||
{
|
||||
if (isAvailable(player))
|
||||
{
|
||||
giveRewards(player);
|
||||
|
||||
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), true);
|
||||
entry.setStatus(DailyMissionStatus.COMPLETED);
|
||||
entry.setLastCompleted(System.currentTimeMillis());
|
||||
storePlayerEntry(entry);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void giveRewards(L2PcInstance player)
|
||||
{
|
||||
_holder.getRewards().forEach(i -> player.addItem("One Day Reward", i, player, true));
|
||||
}
|
||||
|
||||
protected void storePlayerEntry(DailyMissionPlayerEntry entry)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_daily_rewards (charId, rewardId, status, progress, lastCompleted) VALUES (?, ?, ?, ?, ?)"))
|
||||
{
|
||||
ps.setInt(1, entry.getObjectId());
|
||||
ps.setInt(2, entry.getRewardId());
|
||||
ps.setInt(3, entry.getStatus().getClientId());
|
||||
ps.setInt(4, entry.getProgress());
|
||||
ps.setLong(5, entry.getLastCompleted());
|
||||
ps.execute();
|
||||
|
||||
// Cache if not exists
|
||||
_entries.computeIfAbsent(entry.getObjectId(), id -> entry);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Error while saving reward " + entry.getRewardId() + " for player: " + entry.getObjectId() + " in database: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected DailyMissionPlayerEntry getPlayerEntry(int objectId, boolean createIfNone)
|
||||
{
|
||||
final DailyMissionPlayerEntry existingEntry = _entries.get(objectId);
|
||||
if (existingEntry != null)
|
||||
{
|
||||
return existingEntry;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_daily_rewards WHERE charId = ? AND rewardId = ?"))
|
||||
{
|
||||
ps.setInt(1, objectId);
|
||||
ps.setInt(2, _holder.getId());
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
if (rs.next())
|
||||
{
|
||||
final DailyMissionPlayerEntry entry = new DailyMissionPlayerEntry(rs.getInt("charId"), rs.getInt("rewardId"), rs.getInt("status"), rs.getInt("progress"), rs.getLong("lastCompleted"));
|
||||
_entries.put(objectId, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Error while loading reward " + _holder.getId() + " for player: " + objectId + " in database: ", e);
|
||||
}
|
||||
|
||||
if (createIfNone)
|
||||
{
|
||||
final DailyMissionPlayerEntry entry = new DailyMissionPlayerEntry(objectId, _holder.getId());
|
||||
_entries.put(objectId, entry);
|
||||
return entry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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.AffectObject;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
*/
|
||||
public class AffectObjectHandler implements IHandler<IAffectObjectHandler, Enum<AffectObject>>
|
||||
{
|
||||
private final Map<Enum<AffectObject>, IAffectObjectHandler> _datatable;
|
||||
|
||||
protected AffectObjectHandler()
|
||||
{
|
||||
_datatable = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandler(IAffectObjectHandler handler)
|
||||
{
|
||||
_datatable.put(handler.getAffectObjectType(), handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeHandler(IAffectObjectHandler handler)
|
||||
{
|
||||
_datatable.remove(handler.getAffectObjectType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAffectObjectHandler getHandler(Enum<AffectObject> targetType)
|
||||
{
|
||||
return _datatable.get(targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return _datatable.size();
|
||||
}
|
||||
|
||||
public static AffectObjectHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AffectObjectHandler _instance = new AffectObjectHandler();
|
||||
}
|
||||
}
|
@@ -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.AffectScope;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
*/
|
||||
public class AffectScopeHandler implements IHandler<IAffectScopeHandler, Enum<AffectScope>>
|
||||
{
|
||||
private final Map<Enum<AffectScope>, IAffectScopeHandler> _datatable;
|
||||
|
||||
protected AffectScopeHandler()
|
||||
{
|
||||
_datatable = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandler(IAffectScopeHandler handler)
|
||||
{
|
||||
_datatable.put(handler.getAffectScopeType(), handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeHandler(IAffectScopeHandler handler)
|
||||
{
|
||||
_datatable.remove(handler.getAffectScopeType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAffectScopeHandler getHandler(Enum<AffectScope> affectScope)
|
||||
{
|
||||
return _datatable.get(affectScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return _datatable.size();
|
||||
}
|
||||
|
||||
public static AffectScopeHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AffectScopeHandler _instance = new AffectScopeHandler();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.conditions.ICondition;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public final class ConditionHandler
|
||||
{
|
||||
private final Map<String, Function<StatsSet, ICondition>> _conditionHandlerFactories = new HashMap<>();
|
||||
|
||||
public void registerHandler(String name, Function<StatsSet, ICondition> handlerFactory)
|
||||
{
|
||||
_conditionHandlerFactories.put(name, handlerFactory);
|
||||
}
|
||||
|
||||
public Function<StatsSet, ICondition> getHandlerFactory(String name)
|
||||
{
|
||||
return _conditionHandlerFactories.get(name);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return _conditionHandlerFactories.size();
|
||||
}
|
||||
|
||||
public void executeScript()
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeConditionMasterHandler();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Error("Problems while running ConditionMasterHandler", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SingletonHolder
|
||||
{
|
||||
protected static final ConditionHandler _instance = new ConditionHandler();
|
||||
}
|
||||
|
||||
public static ConditionHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.model.DailyMissionDataHolder;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class DailyMissionHandler
|
||||
{
|
||||
private final Map<String, Function<DailyMissionDataHolder, AbstractDailyMissionHandler>> _handlerFactories = new HashMap<>();
|
||||
|
||||
public void registerHandler(String name, Function<DailyMissionDataHolder, AbstractDailyMissionHandler> handlerFactory)
|
||||
{
|
||||
_handlerFactories.put(name, handlerFactory);
|
||||
}
|
||||
|
||||
public Function<DailyMissionDataHolder, AbstractDailyMissionHandler> getHandler(String name)
|
||||
{
|
||||
return _handlerFactories.get(name);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return _handlerFactories.size();
|
||||
}
|
||||
|
||||
public void executeScript()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
ScriptEngineManager.getInstance().executeDailyMissionMasterHandler();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Error("Problems while running DailyMissionMasterHandler", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static DailyMissionHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final DailyMissionHandler _instance = new DailyMissionHandler();
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
* @author BiggBoss, UnAfraid
|
||||
*/
|
||||
public final class EffectHandler
|
||||
{
|
||||
private final Map<String, Function<StatsSet, AbstractEffect>> _effectHandlerFactories = new HashMap<>();
|
||||
|
||||
public void registerHandler(String name, Function<StatsSet, AbstractEffect> handlerFactory)
|
||||
{
|
||||
_effectHandlerFactories.put(name, handlerFactory);
|
||||
}
|
||||
|
||||
public Function<StatsSet, AbstractEffect> getHandlerFactory(String name)
|
||||
{
|
||||
return _effectHandlerFactories.get(name);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return _effectHandlerFactories.size();
|
||||
}
|
||||
|
||||
public void executeScript()
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeEffectMasterHandler();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
@@ -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
|
||||
{
|
||||
Logger _log = Logger.getLogger(IActionHandler.class.getName());
|
||||
|
||||
boolean action(L2PcInstance activeChar, L2Object target, boolean interact);
|
||||
|
||||
InstanceType getInstanceType();
|
||||
}
|
@@ -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
|
||||
{
|
||||
Logger _log = Logger.getLogger(IActionShiftHandler.class.getName());
|
||||
|
||||
boolean action(L2PcInstance activeChar, L2Object target, boolean interact);
|
||||
|
||||
InstanceType getInstanceType();
|
||||
}
|
@@ -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
|
||||
*/
|
||||
boolean useAdminCommand(String command, L2PcInstance activeChar);
|
||||
|
||||
/**
|
||||
* this method is called at initialization to register all the item ids automatically
|
||||
* @return all known itemIds
|
||||
*/
|
||||
String[] getAdminCommandList();
|
||||
}
|
@@ -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.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.targets.AffectObject;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
*/
|
||||
public interface IAffectObjectHandler
|
||||
{
|
||||
/**
|
||||
* Checks if the rules for the given affect object type are accepted or not.
|
||||
* @param activeChar
|
||||
* @param target
|
||||
* @return {@code true} if target should be accepted, {@code false} otherwise
|
||||
**/
|
||||
boolean checkAffectedObject(L2Character activeChar, L2Character target);
|
||||
|
||||
Enum<AffectObject> getAffectObjectType();
|
||||
}
|
@@ -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 java.util.function.Consumer;
|
||||
|
||||
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.AffectScope;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
*/
|
||||
public interface IAffectScopeHandler
|
||||
{
|
||||
void forEachAffected(L2Character activeChar, L2Object target, Skill skill, Consumer<? super L2Object> action);
|
||||
|
||||
Enum<AffectScope> getAffectScopeType();
|
||||
}
|
@@ -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
|
||||
{
|
||||
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
|
||||
*/
|
||||
boolean useBypass(String command, L2PcInstance activeChar, L2Character bypassOrigin);
|
||||
|
||||
/**
|
||||
* This method is called at initialization to register all bypasses automatically.
|
||||
* @return all known bypasses
|
||||
*/
|
||||
String[] getBypassList();
|
||||
}
|
@@ -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
|
||||
*/
|
||||
void handleChat(ChatType type, L2PcInstance activeChar, String target, String text);
|
||||
|
||||
/**
|
||||
* Returns a list of all chat types registered to this handler
|
||||
* @return
|
||||
*/
|
||||
ChatType[] getChatTypeList();
|
||||
}
|
@@ -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>
|
||||
{
|
||||
void registerHandler(K handler);
|
||||
|
||||
void removeHandler(K handler);
|
||||
|
||||
K getHandler(V val);
|
||||
|
||||
int size();
|
||||
}
|
@@ -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
|
||||
{
|
||||
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.
|
||||
*/
|
||||
boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse);
|
||||
}
|
@@ -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
|
||||
{
|
||||
Logger LOG = Logger.getLogger(IParseBoardHandler.class.getName());
|
||||
|
||||
/**
|
||||
* Parses a community board command.
|
||||
* @param command the command
|
||||
* @param player the player
|
||||
* @return
|
||||
*/
|
||||
boolean parseCommunityBoardCommand(String command, L2PcInstance player);
|
||||
|
||||
/**
|
||||
* Gets the community board commands.
|
||||
* @return the community board commands
|
||||
*/
|
||||
String[] getCommunityBoardCommands();
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.ActionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public interface IPlayerActionHandler
|
||||
{
|
||||
void useAction(L2PcInstance activeChar, ActionDataHolder data, boolean ctrlPressed, boolean shiftPressed);
|
||||
}
|
@@ -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
|
||||
{
|
||||
Logger _log = Logger.getLogger(IPunishmentHandler.class.getName());
|
||||
|
||||
void onStart(PunishmentTask task);
|
||||
|
||||
void onEnd(PunishmentTask task);
|
||||
|
||||
PunishmentType getType();
|
||||
}
|
@@ -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 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.TargetType;
|
||||
|
||||
/**
|
||||
* @author Nik
|
||||
*/
|
||||
public interface ITargetTypeHandler
|
||||
{
|
||||
L2Object getTarget(L2Character activeChar, L2Object selectedTarget, Skill skill, boolean forceUse, boolean dontMove, boolean sendMessage);
|
||||
|
||||
Enum<TargetType> getTargetType();
|
||||
}
|
@@ -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
|
||||
{
|
||||
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
|
||||
*/
|
||||
boolean useUserCommand(int id, L2PcInstance activeChar);
|
||||
|
||||
/**
|
||||
* this method is called at initialization to register all the item ids automatically
|
||||
* @return all known itemIds
|
||||
*/
|
||||
int[] getUserCommandList();
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 IVoicedCommandHandler
|
||||
{
|
||||
/**
|
||||
* this is the worker method that is called when someone uses an admin command.
|
||||
* @param activeChar
|
||||
* @param command
|
||||
* @param params
|
||||
* @return command success
|
||||
*/
|
||||
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
|
||||
*/
|
||||
String[] getVoicedCommandList();
|
||||
}
|
@@ -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
|
||||
*/
|
||||
boolean writeCommunityBoardCommand(L2PcInstance player, String arg1, String arg2, String arg3, String arg4, String arg5);
|
||||
}
|
@@ -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 <String ; IItemHandler > 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 PlayerActionHandler implements IHandler<IPlayerActionHandler, String>
|
||||
{
|
||||
private final Map<String, IPlayerActionHandler> _actions = new HashMap<>();
|
||||
|
||||
protected PlayerActionHandler()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandler(IPlayerActionHandler handler)
|
||||
{
|
||||
_actions.put(handler.getClass().getSimpleName(), handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeHandler(IPlayerActionHandler handler)
|
||||
{
|
||||
_actions.remove(handler.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerActionHandler getHandler(String name)
|
||||
{
|
||||
return _actions.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return _actions.size();
|
||||
}
|
||||
|
||||
public static PlayerActionHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerActionHandler _instance = new PlayerActionHandler();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.function.Function;
|
||||
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.skills.ISkillCondition;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public final class SkillConditionHandler
|
||||
{
|
||||
private final Map<String, Function<StatsSet, ISkillCondition>> _skillConditionHandlerFactories = new HashMap<>();
|
||||
|
||||
public void registerHandler(String name, Function<StatsSet, ISkillCondition> handlerFactory)
|
||||
{
|
||||
_skillConditionHandlerFactories.put(name, handlerFactory);
|
||||
}
|
||||
|
||||
public Function<StatsSet, ISkillCondition> getHandlerFactory(String name)
|
||||
{
|
||||
return _skillConditionHandlerFactories.get(name);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return _skillConditionHandlerFactories.size();
|
||||
}
|
||||
|
||||
public void executeScript()
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeSkillConditionMasterHandler();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Error("Problems while running SkillMasterHandler", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SingletonHolder
|
||||
{
|
||||
protected static final SkillConditionHandler _instance = new SkillConditionHandler();
|
||||
}
|
||||
|
||||
public static SkillConditionHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
}
|
@@ -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.TargetType;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class TargetHandler implements IHandler<ITargetTypeHandler, Enum<TargetType>>
|
||||
{
|
||||
private final Map<Enum<TargetType>, 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<TargetType> 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
for (int id : handler.getUserCommandList())
|
||||
{
|
||||
_datatable.put(id, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeHandler(IUserCommandHandler handler)
|
||||
{
|
||||
for (int id : handler.getUserCommandList())
|
||||
{
|
||||
_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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
for (String id : handler.getVoicedCommandList())
|
||||
{
|
||||
_datatable.put(id, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeHandler(IVoicedCommandHandler handler)
|
||||
{
|
||||
for (String id : handler.getVoicedCommandList())
|
||||
{
|
||||
_datatable.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVoicedCommandHandler getHandler(String voicedCommand)
|
||||
{
|
||||
return _datatable.get(voicedCommand.contains(" ") ? voicedCommand.substring(0, voicedCommand.indexOf(" ")) : voicedCommand);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user