IdManager rework.
This commit is contained in:
		@@ -106,7 +106,6 @@ import org.l2jmobius.gameserver.handler.ConditionHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.DailyMissionHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.EffectHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.SkillConditionHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.AirShipManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.BoatManager;
 | 
			
		||||
@@ -125,6 +124,7 @@ import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
 | 
			
		||||
@@ -207,9 +207,9 @@ public class GameServer
 | 
			
		||||
		printSection("ThreadPool");
 | 
			
		||||
		ThreadPool.init();
 | 
			
		||||
		
 | 
			
		||||
		printSection("IdFactory");
 | 
			
		||||
		IdFactory.init();
 | 
			
		||||
		if (!IdFactory.hasInitialized())
 | 
			
		||||
		printSection("IdManager");
 | 
			
		||||
		IdManager.getInstance();
 | 
			
		||||
		if (!IdManager.hasInitialized())
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
 | 
			
		||||
			throw new Exception("Could not initialize the ID factory!");
 | 
			
		||||
@@ -423,7 +423,7 @@ public class GameServer
 | 
			
		||||
		
 | 
			
		||||
		Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
 | 
			
		||||
		
 | 
			
		||||
		LOGGER.info("IdFactory: Free ObjectID's remaining: " + IdFactory.size());
 | 
			
		||||
		LOGGER.info("IdManager: Free ObjectID's remaining: " + IdManager.size());
 | 
			
		||||
		
 | 
			
		||||
		if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
 | 
			
		||||
		{
 | 
			
		||||
 
 | 
			
		||||
@@ -35,10 +35,10 @@ import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.impl.ClanHallData;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.ClanWarState;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.UserInfoType;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.clan.Clan;
 | 
			
		||||
@@ -196,7 +196,7 @@ public class ClanTable
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final Clan clan = new Clan(IdFactory.getNextId(), clanName);
 | 
			
		||||
		final Clan clan = new Clan(IdManager.getInstance().getNextId(), clanName);
 | 
			
		||||
		final ClanMember leader = new ClanMember(clan, player);
 | 
			
		||||
		clan.setLeader(leader);
 | 
			
		||||
		leader.setPlayerInstance(player);
 | 
			
		||||
@@ -271,7 +271,7 @@ public class ClanTable
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		_clans.remove(clanId);
 | 
			
		||||
		IdFactory.releaseId(clanId);
 | 
			
		||||
		IdManager.getInstance().releaseId(clanId);
 | 
			
		||||
		
 | 
			
		||||
		try (Connection con = DatabaseFactory.getConnection())
 | 
			
		||||
		{
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
 | 
			
		||||
import org.l2jmobius.gameserver.engines.DocumentEngine;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.ItemLocation;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.WorldObject;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Attackable;
 | 
			
		||||
@@ -209,7 +209,7 @@ public class ItemTable
 | 
			
		||||
	public ItemInstance createItem(String process, int itemId, long count, Creature actor, Object reference)
 | 
			
		||||
	{
 | 
			
		||||
		// Create and Init the ItemInstance corresponding to the Item Identifier
 | 
			
		||||
		final ItemInstance item = new ItemInstance(IdFactory.getNextId(), itemId);
 | 
			
		||||
		final ItemInstance item = new ItemInstance(IdManager.getInstance().getNextId(), itemId);
 | 
			
		||||
		if (process.equalsIgnoreCase("loot") && !Config.AUTO_LOOT_ITEM_IDS.contains(itemId))
 | 
			
		||||
		{
 | 
			
		||||
			ScheduledFuture<?> itemLootShedule;
 | 
			
		||||
@@ -327,7 +327,7 @@ public class ItemTable
 | 
			
		||||
			item.setLastChange(ItemInstance.REMOVED);
 | 
			
		||||
			
 | 
			
		||||
			World.getInstance().removeObject(item);
 | 
			
		||||
			IdFactory.releaseId(item.getObjectId());
 | 
			
		||||
			IdManager.getInstance().releaseId(item.getObjectId());
 | 
			
		||||
			
 | 
			
		||||
			if (Config.LOG_ITEMS)
 | 
			
		||||
			{
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@
 | 
			
		||||
 * 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.idfactory;
 | 
			
		||||
package org.l2jmobius.gameserver.instancemanager;
 | 
			
		||||
 | 
			
		||||
import java.sql.Connection;
 | 
			
		||||
import java.sql.PreparedStatement;
 | 
			
		||||
@@ -33,39 +33,12 @@ import org.l2jmobius.commons.database.DatabaseFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.util.PrimeFinder;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Mobius (reworked from L2J version)
 | 
			
		||||
 * @author Mobius (reworked from L2J IdFactory)
 | 
			
		||||
 */
 | 
			
		||||
public abstract class IdFactory
 | 
			
		||||
public class IdManager
 | 
			
		||||
{
 | 
			
		||||
	private static final Logger LOGGER = Logger.getLogger(IdFactory.class.getName());
 | 
			
		||||
	private static final Logger LOGGER = Logger.getLogger(IdManager.class.getName());
 | 
			
		||||
	
 | 
			
		||||
	protected static final String[] ID_CHECKS =
 | 
			
		||||
	{
 | 
			
		||||
		"SELECT owner_id    FROM items                 WHERE object_id >= ?   AND object_id < ?",
 | 
			
		||||
		"SELECT object_id   FROM items                 WHERE object_id >= ?   AND object_id < ?",
 | 
			
		||||
		"SELECT charId     FROM character_quests      WHERE charId >= ?     AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_contacts    WHERE charId >= ?     AND charId < ?",
 | 
			
		||||
		"SELECT contactId  FROM character_contacts    WHERE contactId >= ?  AND contactId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_friends     WHERE charId >= ?     AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_friends     WHERE friendId >= ?   AND friendId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_hennas      WHERE charId >= ? AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_recipebook  WHERE charId >= ?     AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_recipeshoplist  WHERE charId >= ?     AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_shortcuts   WHERE charId >= ? AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_macroses    WHERE charId >= ? AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_skills      WHERE charId >= ? AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_skills_save WHERE charId >= ? AND charId < ?",
 | 
			
		||||
		"SELECT charId     FROM character_subclasses  WHERE charId >= ? AND charId < ?",
 | 
			
		||||
		"SELECT charId      FROM characters            WHERE charId >= ?      AND charId < ?",
 | 
			
		||||
		"SELECT clanid      FROM characters            WHERE clanid >= ?      AND clanid < ?",
 | 
			
		||||
		"SELECT clan_id     FROM clan_data             WHERE clan_id >= ?     AND clan_id < ?",
 | 
			
		||||
		"SELECT clan_id     FROM siege_clans           WHERE clan_id >= ?     AND clan_id < ?",
 | 
			
		||||
		"SELECT ally_id     FROM clan_data             WHERE ally_id >= ?     AND ally_id < ?",
 | 
			
		||||
		"SELECT leader_id   FROM clan_data             WHERE leader_id >= ?   AND leader_id < ?",
 | 
			
		||||
		"SELECT item_obj_id FROM pets                  WHERE item_obj_id >= ? AND item_obj_id < ?",
 | 
			
		||||
		"SELECT object_id   FROM itemsonground        WHERE object_id >= ?   AND object_id < ?",
 | 
			
		||||
		"SELECT summonId	FROM characters_summons	WHERE summonId >= ?	AND summonId < ?"
 | 
			
		||||
	};
 | 
			
		||||
	//@formatter:off
 | 
			
		||||
	private static final String[][] ID_EXTRACTS =
 | 
			
		||||
	{
 | 
			
		||||
@@ -76,21 +49,23 @@ public abstract class IdFactory
 | 
			
		||||
		{"messages","messageId"}
 | 
			
		||||
	};
 | 
			
		||||
	//@formatter:on
 | 
			
		||||
	
 | 
			
		||||
	private static final String[] TIMESTAMPS_CLEAN =
 | 
			
		||||
	{
 | 
			
		||||
		"DELETE FROM character_instance_time WHERE time <= ?",
 | 
			
		||||
		"DELETE FROM character_skills_save WHERE restore_type = 1 AND systime <= ?"
 | 
			
		||||
	};
 | 
			
		||||
	public static final int FIRST_OID = 0x10000000;
 | 
			
		||||
	public static final int LAST_OID = 0x7FFFFFFF;
 | 
			
		||||
	public static final int FREE_OBJECT_ID_SIZE = LAST_OID - FIRST_OID;
 | 
			
		||||
	
 | 
			
		||||
	private static final int FIRST_OID = 0x10000000;
 | 
			
		||||
	private static final int LAST_OID = 0x7FFFFFFF;
 | 
			
		||||
	private static final int FREE_OBJECT_ID_SIZE = LAST_OID - FIRST_OID;
 | 
			
		||||
	
 | 
			
		||||
	private static BitSet _freeIds;
 | 
			
		||||
	private static AtomicInteger _freeIdCount;
 | 
			
		||||
	private static AtomicInteger _nextFreeId;
 | 
			
		||||
	private static boolean _initialized;
 | 
			
		||||
	
 | 
			
		||||
	public static void init()
 | 
			
		||||
	public IdManager()
 | 
			
		||||
	{
 | 
			
		||||
		// Update characters online status.
 | 
			
		||||
		try (Connection con = DatabaseFactory.getConnection();
 | 
			
		||||
@@ -101,7 +76,7 @@ public abstract class IdFactory
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.warning("IdFactory: Could not update characters online status: " + e);
 | 
			
		||||
			LOGGER.warning("IdManager: Could not update characters online status: " + e);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Cleanup database.
 | 
			
		||||
@@ -182,11 +157,11 @@ public abstract class IdFactory
 | 
			
		||||
				statement.executeUpdate("UPDATE characters SET clanid=0, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0, clan_join_expiry_time=0, clan_create_expiry_time=0 WHERE characters.clanid > 0 AND characters.clanid NOT IN (SELECT clan_id FROM clan_data);");
 | 
			
		||||
				statement.executeUpdate("UPDATE fort SET owner=0 WHERE owner NOT IN (SELECT clan_id FROM clan_data);");
 | 
			
		||||
				
 | 
			
		||||
				LOGGER.info("IdFactory: Cleaned " + cleanCount + " elements from database in " + ((System.currentTimeMillis() - cleanupStart) / 1000) + " seconds.");
 | 
			
		||||
				LOGGER.info("IdManager: Cleaned " + cleanCount + " elements from database in " + ((System.currentTimeMillis() - cleanupStart) / 1000) + " seconds.");
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception e)
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.warning("IdFactory: Could not clean up database: " + e);
 | 
			
		||||
				LOGGER.warning("IdManager: Could not clean up database: " + e);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
@@ -202,11 +177,11 @@ public abstract class IdFactory
 | 
			
		||||
					cleanCount += statement.executeUpdate();
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			LOGGER.info("IdFactory: Cleaned " + cleanCount + " expired timestamps from database.");
 | 
			
		||||
			LOGGER.info("IdManager: Cleaned " + cleanCount + " expired timestamps from database.");
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.warning("IdFactory: Could not clean expired timestamps from database. " + e);
 | 
			
		||||
			LOGGER.warning("IdManager: Could not clean expired timestamps from database. " + e);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Initialize.
 | 
			
		||||
@@ -243,7 +218,7 @@ public abstract class IdFactory
 | 
			
		||||
				final int objectId = usedObjectId - FIRST_OID;
 | 
			
		||||
				if (objectId < 0)
 | 
			
		||||
				{
 | 
			
		||||
					LOGGER.warning("IdFactory: Object ID " + usedObjectId + " in DB is less than minimum ID of " + FIRST_OID);
 | 
			
		||||
					LOGGER.warning("IdManager: Object ID " + usedObjectId + " in DB is less than minimum ID of " + FIRST_OID);
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
				_freeIds.set(usedObjectId - FIRST_OID);
 | 
			
		||||
@@ -256,7 +231,7 @@ public abstract class IdFactory
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			_initialized = false;
 | 
			
		||||
			LOGGER.severe("IdFactory: Could not be initialized properly: " + e.getMessage());
 | 
			
		||||
			LOGGER.severe("IdManager: Could not be initialized properly: " + e.getMessage());
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Schedule increase capacity task.
 | 
			
		||||
@@ -271,10 +246,10 @@ public abstract class IdFactory
 | 
			
		||||
			}
 | 
			
		||||
		}, 30000, 30000);
 | 
			
		||||
		
 | 
			
		||||
		LOGGER.info("IdFactory: " + _freeIds.size() + " id's available.");
 | 
			
		||||
		LOGGER.info("IdManager: " + _freeIds.size() + " id's available.");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized static void releaseId(int objectId)
 | 
			
		||||
	public void releaseId(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		synchronized (_nextFreeId)
 | 
			
		||||
		{
 | 
			
		||||
@@ -285,12 +260,12 @@ public abstract class IdFactory
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.warning("IdFactory: Release objectID " + objectId + " failed (< " + FIRST_OID + ")");
 | 
			
		||||
				LOGGER.warning("IdManager: Release objectID " + objectId + " failed (< " + FIRST_OID + ")");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized static int getNextId()
 | 
			
		||||
	public int getNextId()
 | 
			
		||||
	{
 | 
			
		||||
		synchronized (_nextFreeId)
 | 
			
		||||
		{
 | 
			
		||||
@@ -303,7 +278,7 @@ public abstract class IdFactory
 | 
			
		||||
			{
 | 
			
		||||
				if (_freeIds.size() >= FREE_OBJECT_ID_SIZE)
 | 
			
		||||
				{
 | 
			
		||||
					throw new NullPointerException("IdFactory: Ran out of valid ids.");
 | 
			
		||||
					throw new NullPointerException("IdManager: Ran out of valid ids.");
 | 
			
		||||
				}
 | 
			
		||||
				increaseBitSetCapacity();
 | 
			
		||||
			}
 | 
			
		||||
@@ -313,14 +288,14 @@ public abstract class IdFactory
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private static void increaseBitSetCapacity()
 | 
			
		||||
	private void increaseBitSetCapacity()
 | 
			
		||||
	{
 | 
			
		||||
		final BitSet newBitSet = new BitSet(PrimeFinder.nextPrime((usedIdCount() * 11) / 10));
 | 
			
		||||
		newBitSet.or(_freeIds);
 | 
			
		||||
		_freeIds = newBitSet;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private static int usedIdCount()
 | 
			
		||||
	private int usedIdCount()
 | 
			
		||||
	{
 | 
			
		||||
		return _freeIdCount.get() - FIRST_OID;
 | 
			
		||||
	}
 | 
			
		||||
@@ -334,4 +309,14 @@ public abstract class IdFactory
 | 
			
		||||
	{
 | 
			
		||||
		return _initialized;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static IdManager getInstance()
 | 
			
		||||
	{
 | 
			
		||||
		return SingletonHolder.INSTANCE;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private static class SingletonHolder
 | 
			
		||||
	{
 | 
			
		||||
		protected static final IdManager INSTANCE = new IdManager();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -31,7 +31,6 @@ import java.util.logging.Logger;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.database.DatabaseFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.MailType;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.entity.Message;
 | 
			
		||||
@@ -277,7 +276,7 @@ public class MailManager
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		_messages.remove(msgId);
 | 
			
		||||
		IdFactory.releaseId(msgId);
 | 
			
		||||
		IdManager.getInstance().releaseId(msgId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.enums.PetitionState;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.PetitionType;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.PetitionManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
@@ -47,7 +47,7 @@ public class Petition
 | 
			
		||||
	
 | 
			
		||||
	public Petition(PlayerInstance petitioner, String petitionText, int petitionType)
 | 
			
		||||
	{
 | 
			
		||||
		_id = IdFactory.getNextId();
 | 
			
		||||
		_id = IdManager.getInstance().getNextId();
 | 
			
		||||
		_type = PetitionType.values()[petitionType - 1];
 | 
			
		||||
		_content = petitionText;
 | 
			
		||||
		_petitioner = petitioner;
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import org.l2jmobius.gameserver.handler.ActionHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.ActionShiftHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.IActionHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.IActionShiftHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Creature;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
 | 
			
		||||
@@ -154,8 +154,8 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
 | 
			
		||||
	public void refreshId()
 | 
			
		||||
	{
 | 
			
		||||
		World.getInstance().removeObject(this);
 | 
			
		||||
		IdFactory.releaseId(getObjectId());
 | 
			
		||||
		_objectId = IdFactory.getNextId();
 | 
			
		||||
		IdManager.getInstance().releaseId(getObjectId());
 | 
			
		||||
		_objectId = IdManager.getInstance().getNextId();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ import org.l2jmobius.gameserver.enums.Team;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.TeleportWhereType;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.UserInfoType;
 | 
			
		||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.QuestManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
 | 
			
		||||
@@ -288,7 +288,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
 | 
			
		||||
	 */
 | 
			
		||||
	public Creature(CreatureTemplate template)
 | 
			
		||||
	{
 | 
			
		||||
		this(IdFactory.getNextId(), template);
 | 
			
		||||
		this(IdManager.getInstance().getNextId(), template);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ import java.util.concurrent.Future;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.concurrent.ThreadPool;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.InstanceType;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.stat.ControllableAirShipStat;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
 | 
			
		||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
 | 
			
		||||
@@ -48,7 +48,7 @@ public class ControllableAirShipInstance extends AirShipInstance
 | 
			
		||||
		super(template);
 | 
			
		||||
		setInstanceType(InstanceType.ControllableAirShipInstance);
 | 
			
		||||
		_ownerId = ownerId;
 | 
			
		||||
		_helmId = IdFactory.getNextId(); // not forget to release !
 | 
			
		||||
		_helmId = IdManager.getInstance().getNextId(); // not forget to release !
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
@@ -282,8 +282,8 @@ public class ControllableAirShipInstance extends AirShipInstance
 | 
			
		||||
	public void refreshId()
 | 
			
		||||
	{
 | 
			
		||||
		super.refreshId();
 | 
			
		||||
		IdFactory.releaseId(_helmId);
 | 
			
		||||
		_helmId = IdFactory.getNextId();
 | 
			
		||||
		IdManager.getInstance().releaseId(_helmId);
 | 
			
		||||
		_helmId = IdManager.getInstance().getNextId();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ package org.l2jmobius.gameserver.model.actor.instance;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.impl.FenceData;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.FenceState;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.WorldObject;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Creature;
 | 
			
		||||
@@ -44,7 +44,7 @@ public class FenceInstance extends WorldObject
 | 
			
		||||
	
 | 
			
		||||
	public FenceInstance(int x, int y, String name, int width, int length, int height, FenceState state)
 | 
			
		||||
	{
 | 
			
		||||
		super(IdFactory.getNextId());
 | 
			
		||||
		super(IdManager.getInstance().getNextId());
 | 
			
		||||
		
 | 
			
		||||
		_xMin = x - (width / 2);
 | 
			
		||||
		_xMax = x + (width / 2);
 | 
			
		||||
@@ -59,7 +59,7 @@ public class FenceInstance extends WorldObject
 | 
			
		||||
			_heightFences = new int[height - 1];
 | 
			
		||||
			for (int i = 0; i < _heightFences.length; i++)
 | 
			
		||||
			{
 | 
			
		||||
				_heightFences[i] = IdFactory.getNextId();
 | 
			
		||||
				_heightFences[i] = IdManager.getInstance().getNextId();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -107,7 +107,6 @@ import org.l2jmobius.gameserver.enums.UserInfoType;
 | 
			
		||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.IItemHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.ItemHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
 | 
			
		||||
@@ -116,6 +115,7 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.MentorManager;
 | 
			
		||||
@@ -1159,7 +1159,7 @@ public class PlayerInstance extends Playable
 | 
			
		||||
	 */
 | 
			
		||||
	private PlayerInstance(PlayerTemplate template, String accountName, PlayerAppearance app)
 | 
			
		||||
	{
 | 
			
		||||
		this(IdFactory.getNextId(), template, accountName, app);
 | 
			
		||||
		this(IdManager.getInstance().getNextId(), template, accountName, app);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import java.util.Locale;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
import org.l2jmobius.commons.util.StringUtil;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace.HistoryInfo;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace.RaceState;
 | 
			
		||||
@@ -160,7 +160,7 @@ public class RaceManagerInstance extends Npc
 | 
			
		||||
				
 | 
			
		||||
				player.setRace(0, 0);
 | 
			
		||||
				player.setRace(1, 0);
 | 
			
		||||
				ItemInstance item = new ItemInstance(IdFactory.getNextId(), 4443);
 | 
			
		||||
				ItemInstance item = new ItemInstance(IdManager.getInstance().getNextId(), 4443);
 | 
			
		||||
				item.setCount(1);
 | 
			
		||||
				item.setEnchantLevel(MonsterRace.getInstance().getRaceNumber());
 | 
			
		||||
				item.setCustomType1(ticket);
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ package org.l2jmobius.gameserver.model.announce;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.script.DateRange;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -32,7 +32,7 @@ public class EventAnnouncement implements IAnnouncement
 | 
			
		||||
	
 | 
			
		||||
	public EventAnnouncement(DateRange range, String content)
 | 
			
		||||
	{
 | 
			
		||||
		_id = IdFactory.getNextId();
 | 
			
		||||
		_id = IdManager.getInstance().getNextId();
 | 
			
		||||
		_range = range;
 | 
			
		||||
		_content = content;
 | 
			
		||||
	}
 | 
			
		||||
@@ -88,7 +88,7 @@ public class EventAnnouncement implements IAnnouncement
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean deleteMe()
 | 
			
		||||
	{
 | 
			
		||||
		IdFactory.releaseId(_id);
 | 
			
		||||
		IdManager.getInstance().releaseId(_id);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import java.util.logging.Level;
 | 
			
		||||
import java.util.logging.Logger;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.database.DatabaseFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -85,7 +85,7 @@ public class Couple
 | 
			
		||||
		try (Connection con = DatabaseFactory.getConnection();
 | 
			
		||||
			PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
 | 
			
		||||
		{
 | 
			
		||||
			_id = IdFactory.getNextId();
 | 
			
		||||
			_id = IdManager.getInstance().getNextId();
 | 
			
		||||
			ps.setInt(1, _id);
 | 
			
		||||
			ps.setInt(2, _player1Id);
 | 
			
		||||
			ps.setInt(3, _player2Id);
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import java.sql.SQLException;
 | 
			
		||||
import org.l2jmobius.gameserver.data.sql.impl.CharNameTable;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.AttributeType;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.MailType;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.itemcontainer.Mail;
 | 
			
		||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
 | 
			
		||||
@@ -99,7 +99,7 @@ public class Message
 | 
			
		||||
	 */
 | 
			
		||||
	public Message(int senderId, int receiverId, boolean isCod, String subject, String text, long reqAdena)
 | 
			
		||||
	{
 | 
			
		||||
		_messageId = IdFactory.getNextId();
 | 
			
		||||
		_messageId = IdManager.getInstance().getNextId();
 | 
			
		||||
		_senderId = senderId;
 | 
			
		||||
		_receiverId = receiverId;
 | 
			
		||||
		_subject = subject;
 | 
			
		||||
@@ -118,7 +118,7 @@ public class Message
 | 
			
		||||
	 */
 | 
			
		||||
	public Message(int receiverId, String subject, String content, MailType sendBySystem)
 | 
			
		||||
	{
 | 
			
		||||
		_messageId = IdFactory.getNextId();
 | 
			
		||||
		_messageId = IdManager.getInstance().getNextId();
 | 
			
		||||
		_senderId = -1;
 | 
			
		||||
		_receiverId = receiverId;
 | 
			
		||||
		_subject = subject;
 | 
			
		||||
@@ -138,7 +138,7 @@ public class Message
 | 
			
		||||
	 */
 | 
			
		||||
	public Message(int senderId, int receiverId, String subject, String content, MailType sendBySystem)
 | 
			
		||||
	{
 | 
			
		||||
		_messageId = IdFactory.getNextId();
 | 
			
		||||
		_messageId = IdManager.getInstance().getNextId();
 | 
			
		||||
		_senderId = senderId;
 | 
			
		||||
		_receiverId = receiverId;
 | 
			
		||||
		_subject = subject;
 | 
			
		||||
@@ -157,7 +157,7 @@ public class Message
 | 
			
		||||
	 */
 | 
			
		||||
	public Message(Message msg)
 | 
			
		||||
	{
 | 
			
		||||
		_messageId = IdFactory.getNextId();
 | 
			
		||||
		_messageId = IdManager.getInstance().getNextId();
 | 
			
		||||
		_senderId = msg.getSenderId();
 | 
			
		||||
		_receiverId = msg.getSenderId();
 | 
			
		||||
		_subject = "";
 | 
			
		||||
@@ -177,7 +177,7 @@ public class Message
 | 
			
		||||
	
 | 
			
		||||
	public Message(int receiverId, ItemInstance item, MailType mailType)
 | 
			
		||||
	{
 | 
			
		||||
		_messageId = IdFactory.getNextId();
 | 
			
		||||
		_messageId = IdManager.getInstance().getNextId();
 | 
			
		||||
		_senderId = -1;
 | 
			
		||||
		_receiverId = receiverId;
 | 
			
		||||
		_subject = "";
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
package org.l2jmobius.gameserver.model.itemauction;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.datatables.ItemTable;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.StatSet;
 | 
			
		||||
import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
 | 
			
		||||
@@ -78,7 +78,7 @@ public class AuctionItem
 | 
			
		||||
	
 | 
			
		||||
	public ItemInstance createNewItemInstance()
 | 
			
		||||
	{
 | 
			
		||||
		final ItemInstance item = new ItemInstance(IdFactory.getNextId(), _itemId);
 | 
			
		||||
		final ItemInstance item = new ItemInstance(IdManager.getInstance().getNextId(), _itemId);
 | 
			
		||||
		World.getInstance().addObject(item);
 | 
			
		||||
		item.setCount(_itemCount);
 | 
			
		||||
		item.setEnchantLevel(item.getItem().getDefaultEnchantLevel());
 | 
			
		||||
 
 | 
			
		||||
@@ -47,8 +47,8 @@ import org.l2jmobius.gameserver.enums.ItemLocation;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.ItemSkillType;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.UserInfoType;
 | 
			
		||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.SiegeGuardManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.DropProtection;
 | 
			
		||||
@@ -259,7 +259,7 @@ public class ItemInstance extends WorldObject
 | 
			
		||||
	 */
 | 
			
		||||
	public ItemInstance(int itemId)
 | 
			
		||||
	{
 | 
			
		||||
		this(IdFactory.getNextId(), itemId);
 | 
			
		||||
		this(IdManager.getInstance().getNextId(), itemId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.zone;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.IdManager;
 | 
			
		||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
 | 
			
		||||
import org.l2jmobius.gameserver.model.Location;
 | 
			
		||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
 | 
			
		||||
@@ -50,7 +50,7 @@ public abstract class ZoneForm
 | 
			
		||||
	
 | 
			
		||||
	protected final void dropDebugItem(int itemId, int num, int x, int y, int z)
 | 
			
		||||
	{
 | 
			
		||||
		final ItemInstance item = new ItemInstance(IdFactory.getNextId(), itemId);
 | 
			
		||||
		final ItemInstance item = new ItemInstance(IdManager.getInstance().getNextId(), itemId);
 | 
			
		||||
		item.setCount(num);
 | 
			
		||||
		item.spawnMe(x, y, z + 5);
 | 
			
		||||
		ZoneManager.getInstance().getDebugItems().add(item);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user