Merged with released L2J-Unity files.
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.OneDayRewardStatus;
|
||||
import com.l2jmobius.gameserver.model.OneDayRewardDataHolder;
|
||||
import com.l2jmobius.gameserver.model.OneDayRewardPlayerEntry;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.ListenersContainer;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public abstract class AbstractOneDayRewardHandler extends ListenersContainer
|
||||
{
|
||||
protected Logger LOGGER = Logger.getLogger(getClass().getName());
|
||||
|
||||
private final Map<Integer, OneDayRewardPlayerEntry> _entries = new ConcurrentHashMap<>();
|
||||
private final OneDayRewardDataHolder _holder;
|
||||
|
||||
protected AbstractOneDayRewardHandler(OneDayRewardDataHolder holder)
|
||||
{
|
||||
_holder = holder;
|
||||
init();
|
||||
}
|
||||
|
||||
public OneDayRewardDataHolder getHolder()
|
||||
{
|
||||
return _holder;
|
||||
}
|
||||
|
||||
public abstract boolean isAvailable(L2PcInstance player);
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public int getStatus(L2PcInstance player)
|
||||
{
|
||||
final OneDayRewardPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
|
||||
return entry != null ? entry.getStatus().getClientId() : OneDayRewardStatus.NOT_AVAILABLE.getClientId();
|
||||
}
|
||||
|
||||
public int getProgress(L2PcInstance player)
|
||||
{
|
||||
final OneDayRewardPlayerEntry 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, OneDayRewardStatus.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 OneDayRewardPlayerEntry entry = getPlayerEntry(player.getObjectId(), true);
|
||||
entry.setStatus(OneDayRewardStatus.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(OneDayRewardPlayerEntry 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 OneDayRewardPlayerEntry getPlayerEntry(int objectId, boolean createIfNone)
|
||||
{
|
||||
final OneDayRewardPlayerEntry 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 OneDayRewardPlayerEntry entry = new OneDayRewardPlayerEntry(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 OneDayRewardPlayerEntry entry = new OneDayRewardPlayerEntry(objectId, _holder.getId());
|
||||
_entries.put(objectId, entry);
|
||||
return entry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +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)
|
||||
{
|
||||
for (String id : handler.getAdminCommandList())
|
||||
{
|
||||
_datatable.put(id, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeHandler(IAdminCommandHandler handler)
|
||||
{
|
||||
for (String id : handler.getAdminCommandList())
|
||||
{
|
||||
_datatable.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAdminCommandHandler getHandler(String adminCommand)
|
||||
{
|
||||
return _datatable.get(adminCommand.contains(" ") ? adminCommand.substring(0, adminCommand.indexOf(" ")) : adminCommand);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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,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;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +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.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
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(new File(L2ScriptEngineManager.SCRIPT_FOLDER, "handlers/EffectMasterHandler.java"));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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,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();
|
||||
}
|
||||
@@ -1,45 +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 java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public interface ITelnetHandler
|
||||
{
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
String[] getCommandList();
|
||||
}
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
@@ -1,34 +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.L2TargetType;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public interface ITargetTypeHandler
|
||||
{
|
||||
L2Object[] EMPTY_TARGET_LIST = new L2Object[0];
|
||||
|
||||
L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target);
|
||||
|
||||
Enum<L2TargetType> getTargetType();
|
||||
}
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
|
||||
@@ -1,41 +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 java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public interface IVoicedCommandHandler
|
||||
{
|
||||
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
|
||||
*/
|
||||
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();
|
||||
}
|
||||
/*
|
||||
* 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,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.OneDayRewardDataHolder;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class OneDayRewardHandler
|
||||
{
|
||||
private final Map<String, Function<OneDayRewardDataHolder, AbstractOneDayRewardHandler>> _handlerFactories = new HashMap<>();
|
||||
|
||||
public void registerHandler(String name, Function<OneDayRewardDataHolder, AbstractOneDayRewardHandler> handlerFactory)
|
||||
{
|
||||
_handlerFactories.put(name, handlerFactory);
|
||||
}
|
||||
|
||||
public Function<OneDayRewardDataHolder, AbstractOneDayRewardHandler> getHandler(String name)
|
||||
{
|
||||
return _handlerFactories.get(name);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return _handlerFactories.size();
|
||||
}
|
||||
|
||||
public void executeScript()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
ScriptEngineManager.getInstance().executeOneDayRewardMasterHandler();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Error("Problems while running OneDayRewardMasterHandler", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static OneDayRewardHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final OneDayRewardHandler _instance = new OneDayRewardHandler();
|
||||
}
|
||||
}
|
||||
@@ -1,78 +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 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();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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,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;
|
||||
}
|
||||
}
|
||||
@@ -1,69 +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();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user