Removal of unused FactionManager class.
This commit is contained in:
@@ -115,7 +115,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -296,11 +295,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -119,7 +119,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -304,11 +303,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -119,7 +119,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -304,11 +303,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -119,7 +119,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -303,11 +302,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -121,7 +121,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -305,11 +304,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -121,7 +121,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -305,11 +304,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -122,7 +122,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -307,11 +306,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -124,7 +124,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -310,11 +309,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -124,7 +124,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -310,11 +309,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -125,7 +125,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -312,11 +311,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -127,7 +127,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -316,11 +315,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -127,7 +127,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||||
@@ -316,11 +315,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -106,7 +106,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
|
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
|
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
@@ -279,11 +278,6 @@ public class GameServer
|
|||||||
PetDataTable.getInstance();
|
PetDataTable.getInstance();
|
||||||
CharSummonTable.getInstance().init();
|
CharSummonTable.getInstance().init();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -107,7 +107,6 @@ import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
|
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
|
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||||
@@ -281,11 +280,6 @@ public class GameServer
|
|||||||
PetDataTable.getInstance();
|
PetDataTable.getInstance();
|
||||||
CharSummonTable.getInstance().init();
|
CharSummonTable.getInstance().init();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -114,13 +114,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -128,6 +126,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -303,11 +302,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -114,13 +114,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -128,6 +126,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -303,11 +302,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -115,13 +115,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -129,6 +127,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -305,11 +304,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -116,13 +116,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -130,6 +128,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -307,11 +306,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -117,13 +117,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -131,6 +129,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -309,11 +308,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -119,13 +119,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -133,6 +131,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -312,11 +311,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -112,13 +112,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -126,6 +124,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -298,11 +297,6 @@ public class GameServer
|
|||||||
BeautyShopData.getInstance();
|
BeautyShopData.getInstance();
|
||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -126,13 +126,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -140,6 +138,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -325,11 +324,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -130,13 +130,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -144,6 +142,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -335,11 +334,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -130,13 +130,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -144,6 +142,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -335,11 +334,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -130,13 +130,11 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
import org.l2jmobius.gameserver.instancemanager.CustomMailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
import org.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.FactionManager;
|
|
||||||
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
import org.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||||
@@ -144,6 +142,7 @@ import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
|||||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
import org.l2jmobius.gameserver.instancemanager.IdManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||||
|
import org.l2jmobius.gameserver.instancemanager.ItemCommissionManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||||
@@ -335,11 +334,6 @@ public class GameServer
|
|||||||
MentorManager.getInstance();
|
MentorManager.getInstance();
|
||||||
VipManager.getInstance();
|
VipManager.getInstance();
|
||||||
|
|
||||||
if (Config.FACTION_SYSTEM_ENABLED)
|
|
||||||
{
|
|
||||||
FactionManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||||
{
|
{
|
||||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains objectId and factionId for all players.
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class FactionManager
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FactionManager.class.getName());
|
|
||||||
private final Map<Integer, Integer> _playerFactions = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
protected FactionManager()
|
|
||||||
{
|
|
||||||
loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadAll()
|
|
||||||
{
|
|
||||||
_playerFactions.clear();
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
Statement s = con.createStatement();
|
|
||||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
|
||||||
{
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
_playerFactions.put(rs.getInt(1), rs.getInt(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not load character faction information: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _playerFactions.size() + " character faction values.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFactionByCharId(int id)
|
|
||||||
{
|
|
||||||
if (id <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer factionId = _playerFactions.get(id);
|
|
||||||
if (factionId != null)
|
|
||||||
{
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection();
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
|
||||||
{
|
|
||||||
ps.setInt(1, id);
|
|
||||||
try (ResultSet rset = ps.executeQuery())
|
|
||||||
{
|
|
||||||
if (rset.next())
|
|
||||||
{
|
|
||||||
factionId = rset.getInt(1);
|
|
||||||
_playerFactions.put(id, factionId);
|
|
||||||
return factionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Could not check existing char id: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameFaction(Player player1, Player player2)
|
|
||||||
{
|
|
||||||
// TODO: Maybe add support for multiple factions?
|
|
||||||
return (player1.isGood() && player2.isGood()) || (player1.isEvil() && player2.isEvil());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FactionManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final FactionManager INSTANCE = new FactionManager();
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user