Parcourir la source

BETA: Removed `L2FastList` class.

Nos il y a 11 ans
Parent
commit
1adfe9b3d5

+ 10 - 13
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ClanTable.java

@@ -29,6 +29,8 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javolution.util.FastList;
+
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
@@ -62,7 +64,6 @@ import com.l2jserver.gameserver.scripting.scriptengine.impl.L2Script.EventStage;
 import com.l2jserver.gameserver.scripting.scriptengine.listeners.clan.ClanWarListener;
 import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.EnumIntBitmask;
-import com.l2jserver.util.L2FastList;
 
 /**
  * This class loads the clan related data.
@@ -71,7 +72,7 @@ public class ClanTable
 {
 	private static final Logger _log = Logger.getLogger(ClanTable.class.getName());
 	
-	private static List<ClanWarListener> clanWarListeners = new L2FastList<>(true);
+	private static List<ClanWarListener> clanWarListeners = new FastList<ClanWarListener>().shared();
 	
 	private final Map<Integer, L2Clan> _clans = new HashMap<>();
 	
@@ -353,19 +354,15 @@ public class ClanTable
 	
 	public void scheduleRemoveClan(final int clanId)
 	{
-		ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+		ThreadPoolManager.getInstance().scheduleGeneral(() ->
 		{
-			@Override
-			public void run()
+			if (getClan(clanId) == null)
 			{
-				if (getClan(clanId) == null)
-				{
-					return;
-				}
-				if (getClan(clanId).getDissolvingExpiryTime() != 0)
-				{
-					destroyClan(clanId);
-				}
+				return;
+			}
+			if (getClan(clanId).getDissolvingExpiryTime() != 0)
+			{
+				destroyClan(clanId);
 			}
 		}, Math.max(getClan(clanId).getDissolvingExpiryTime() - System.currentTimeMillis(), 300000));
 	}

+ 8 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/GrandBossManager.java

@@ -23,13 +23,16 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import com.l2jserver.L2DatabaseFactory;
@@ -44,7 +47,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.interfaces.IStorable;
 import com.l2jserver.gameserver.model.zone.type.L2BossZone;
-import com.l2jserver.util.L2FastList;
 
 /**
  * Grand Boss manager.
@@ -66,7 +68,7 @@ public final class GrandBossManager implements IStorable
 	
 	private final Map<Integer, Integer> _bossStatus = new HashMap<>();
 	
-	private final L2FastList<L2BossZone> _zones = new L2FastList<>();
+	private final List<L2BossZone> _zones = new FastList<>();
 	
 	protected GrandBossManager()
 	{
@@ -123,7 +125,7 @@ public final class GrandBossManager implements IStorable
 	 */
 	public void initZones()
 	{
-		FastMap<Integer, L2FastList<Integer>> zones = new FastMap<>();
+		Map<Integer, List<Integer>> zones = new HashMap<>();
 		
 		if (_zones == null)
 		{
@@ -137,7 +139,7 @@ public final class GrandBossManager implements IStorable
 			{
 				continue;
 			}
-			zones.put(zone.getId(), new L2FastList<Integer>());
+			zones.put(zone.getId(), new ArrayList<>());
 		}
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
@@ -314,7 +316,7 @@ public final class GrandBossManager implements IStorable
 						continue;
 					}
 					Integer id = zone.getId();
-					L2FastList<Integer> list = zone.getAllowedPlayers();
+					List<Integer> list = zone.getAllowedPlayers();
 					if ((list == null) || list.isEmpty())
 					{
 						continue;
@@ -435,7 +437,7 @@ public final class GrandBossManager implements IStorable
 		_zones.clear();
 	}
 	
-	public L2FastList<L2BossZone> getZones()
+	public List<L2BossZone> getZones()
 	{
 		return _zones;
 	}

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ItemsOnGroundManager.java

@@ -27,13 +27,14 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javolution.util.FastList;
+
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.ItemsAutoDestroy;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
-import com.l2jserver.util.L2FastList;
 
 /**
  * This class manage all items on ground.
@@ -43,7 +44,7 @@ public final class ItemsOnGroundManager implements Runnable
 {
 	private static final Logger _log = Logger.getLogger(ItemsOnGroundManager.class.getName());
 	
-	private final List<L2ItemInstance> _items = new L2FastList<>(true);
+	private final List<L2ItemInstance> _items = new FastList<L2ItemInstance>().shared();
 	
 	protected ItemsOnGroundManager()
 	{

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Instance.java

@@ -32,6 +32,7 @@ import java.util.logging.Logger;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import org.w3c.dom.Document;
@@ -63,7 +64,6 @@ import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.clientpackets.Say2;
 import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
-import com.l2jserver.util.L2FastList;
 
 /**
  * Main class for game instances.
@@ -78,8 +78,8 @@ public final class Instance
 	private int _ejectTime = Config.EJECT_DEAD_PLAYER_TIME;
 	/** Allow random walk for NPCs, global parameter. */
 	private boolean _allowRandomWalk = true;
-	private final L2FastList<Integer> _players = new L2FastList<>(true);
-	private final List<L2Npc> _npcs = new L2FastList<>(true);
+	private final List<Integer> _players = new FastList<Integer>().shared();
+	private final List<L2Npc> _npcs = new FastList<L2Npc>().shared();
 	private final Map<Integer, L2DoorInstance> _doors = new ConcurrentHashMap<>();
 	private final Map<String, List<L2Spawn>> _manualSpawn = new HashMap<>();
 	private Location _spawnLoc = null;

+ 65 - 83
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java

@@ -24,8 +24,10 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
@@ -34,6 +36,7 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import com.l2jserver.Config;
@@ -47,7 +50,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Hero;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
-import com.l2jserver.util.L2FastList;
 
 /**
  * @author godson
@@ -58,7 +60,7 @@ public class Olympiad
 	protected static final Logger _logResults = Logger.getLogger("olympiad");
 	
 	private static final Map<Integer, StatsSet> _nobles = new FastMap<>();
-	protected static L2FastList<StatsSet> _heroesToBe;
+	protected static List<StatsSet> _heroesToBe;
 	private static final Map<Integer, Integer> _noblesRank = new HashMap<>();
 	
 	public static final String OLYMPIAD_HTML_PATH = "data/html/olympiad/";
@@ -469,84 +471,69 @@ public class Olympiad
 			_log.info("Olympiad System: Event starts/started : " + _compStart.getTime());
 		}
 		
-		_scheduledCompStart = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+		_scheduledCompStart = ThreadPoolManager.getInstance().scheduleGeneral(() ->
 		{
-			@Override
-			public void run()
+			if (isOlympiadEnd())
+			{
+				return;
+			}
+			
+			_inCompPeriod = true;
+			
+			Announcements.getInstance().announceToAll(SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_HAS_STARTED));
+			_log.info("Olympiad System: Olympiad Game Started");
+			_logResults.info("Result,Player1,Player2,Player1 HP,Player2 HP,Player1 Damage,Player2 Damage,Points,Classed");
+			
+			_gameManager = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(OlympiadGameManager.getInstance(), 30000, 30000);
+			if (Config.ALT_OLY_ANNOUNCE_GAMES)
+			{
+				_gameAnnouncer = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new OlympiadAnnouncer(), 30000, 500);
+			}
+			
+			long regEnd = getMillisToCompEnd() - 600000;
+			if (regEnd > 0)
+			{
+				ThreadPoolManager.getInstance().scheduleGeneral(() -> Announcements.getInstance().announceToAll(SystemMessage.getSystemMessage(SystemMessageId.OLYMPIAD_REGISTRATION_PERIOD_ENDED)), regEnd);
+			}
+			
+			_scheduledCompEnd = ThreadPoolManager.getInstance().scheduleGeneral(() ->
 			{
 				if (isOlympiadEnd())
 				{
 					return;
 				}
+				_inCompPeriod = false;
+				Announcements.getInstance().announceToAll(SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_HAS_ENDED));
+				_log.info("Olympiad System: Olympiad Game Ended");
 				
-				_inCompPeriod = true;
-				
-				Announcements.getInstance().announceToAll(SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_HAS_STARTED));
-				_log.info("Olympiad System: Olympiad Game Started");
-				_logResults.info("Result,Player1,Player2,Player1 HP,Player2 HP,Player1 Damage,Player2 Damage,Points,Classed");
-				
-				_gameManager = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(OlympiadGameManager.getInstance(), 30000, 30000);
-				if (Config.ALT_OLY_ANNOUNCE_GAMES)
+				while (OlympiadGameManager.getInstance().isBattleStarted()) // cleared in game manager
 				{
-					_gameAnnouncer = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new OlympiadAnnouncer(), 30000, 500);
+					try
+					{
+						// wait 1 minutes for end of pendings games
+						Thread.sleep(60000);
+					}
+					catch (InterruptedException e)
+					{
+					}
 				}
 				
-				long regEnd = getMillisToCompEnd() - 600000;
-				if (regEnd > 0)
+				if (_gameManager != null)
 				{
-					ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
-					{
-						@Override
-						public void run()
-						{
-							Announcements.getInstance().announceToAll(SystemMessage.getSystemMessage(SystemMessageId.OLYMPIAD_REGISTRATION_PERIOD_ENDED));
-						}
-					}, regEnd);
+					_gameManager.cancel(false);
+					_gameManager = null;
 				}
 				
-				_scheduledCompEnd = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+				if (_gameAnnouncer != null)
 				{
-					@Override
-					public void run()
-					{
-						if (isOlympiadEnd())
-						{
-							return;
-						}
-						_inCompPeriod = false;
-						Announcements.getInstance().announceToAll(SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_HAS_ENDED));
-						_log.info("Olympiad System: Olympiad Game Ended");
-						
-						while (OlympiadGameManager.getInstance().isBattleStarted()) // cleared in game manager
-						{
-							try
-							{
-								// wait 1 minutes for end of pendings games
-								Thread.sleep(60000);
-							}
-							catch (InterruptedException e)
-							{
-							}
-						}
-						
-						if (_gameManager != null)
-						{
-							_gameManager.cancel(false);
-							_gameManager = null;
-						}
-						
-						if (_gameAnnouncer != null)
-						{
-							_gameAnnouncer.cancel(false);
-							_gameAnnouncer = null;
-						}
-						
-						saveOlympiadStatus();
-						
-						init();
-					}
-				}, getMillisToCompEnd());
-			}
+					_gameAnnouncer.cancel(false);
+					_gameAnnouncer = null;
+				}
+				
+				saveOlympiadStatus();
+				
+				init();
+			}, getMillisToCompEnd());
 		}, getMillisToCompBegin());
 	}
 	
@@ -653,19 +640,15 @@ public class Olympiad
 	
 	private void scheduleWeeklyChange()
 	{
-		_scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
+		_scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
 		{
-			@Override
-			public void run()
-			{
-				addWeeklyPoints();
-				_log.info("Olympiad System: Added weekly points to nobles");
-				resetWeeklyMatches();
-				_log.info("Olympiad System: Reset weekly matches to nobles");
-				
-				Calendar nextChange = Calendar.getInstance();
-				_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
-			}
+			addWeeklyPoints();
+			_log.info("Olympiad System: Added weekly points to nobles");
+			resetWeeklyMatches();
+			_log.info("Olympiad System: Reset weekly matches to nobles");
+			
+			Calendar nextChange = Calendar.getInstance();
+			_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
 		}, getMillisToWeekChange(), WEEKLY_PERIOD);
 	}
 	
@@ -888,14 +871,14 @@ public class Olympiad
 			}
 		}
 		
-		_heroesToBe = new L2FastList<>();
+		_heroesToBe = new FastList<>();
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
 		{
 			ResultSet rset;
 			StatsSet hero;
-			L2FastList<StatsSet> soulHounds = new L2FastList<>();
+			List<StatsSet> soulHounds = new ArrayList<>();
 			for (int element : HERO_IDS)
 			{
 				statement.setInt(1, element);
@@ -1020,10 +1003,9 @@ public class Olympiad
 		}
 	}
 	
-	public L2FastList<String> getClassLeaderBoard(int classId)
+	public List<String> getClassLeaderBoard(int classId)
 	{
-		// if (_period != 1) return;
-		final L2FastList<String> names = new L2FastList<>();
+		final List<String> names = new ArrayList<>();
 		String query = Config.ALT_OLY_SHOW_MONTHLY_WINNERS ? ((classId == 132) ? GET_EACH_CLASS_LEADER_SOULHOUND : GET_EACH_CLASS_LEADER) : ((classId == 132) ? GET_EACH_CLASS_LEADER_CURRENT_SOULHOUND : GET_EACH_CLASS_LEADER_CURRENT);
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(query))

+ 10 - 12
L2J_Server_BETA/java/com/l2jserver/gameserver/model/zone/type/L2BossZone.java

@@ -18,8 +18,10 @@
  */
 package com.l2jserver.gameserver.model.zone.type;
 
+import java.util.List;
 import java.util.Map;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import com.l2jserver.gameserver.GameServer;
@@ -35,7 +37,6 @@ import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
 import com.l2jserver.gameserver.model.zone.L2ZoneType;
-import com.l2jserver.util.L2FastList;
 
 /**
  * @author DaRkRaGe
@@ -56,32 +57,29 @@ public class L2BossZone extends L2ZoneType
 		// track the times that players got disconnected. Players are allowed
 		// to log back into the zone as long as their log-out was within _timeInvade time...
 		// <player objectId, expiration time in milliseconds>
-		private final FastMap<Integer, Long> _playerAllowedReEntryTimes;
+		private final Map<Integer, Long> _playerAllowedReEntryTimes = new FastMap<>();
 		
 		// track the players admitted to the zone who should be allowed back in
 		// after reboot/server downtime (outside of their control), within 30 of server restart
-		private final L2FastList<Integer> _playersAllowed;
+		private final List<Integer> _playersAllowed = new FastList<>();
 		
-		private final L2FastList<L2Character> _raidList;
+		private final List<L2Character> _raidList = new FastList<>();
 		
 		public Settings()
 		{
-			_playerAllowedReEntryTimes = new FastMap<>();
-			_playersAllowed = new L2FastList<>();
-			_raidList = new L2FastList<>();
 		}
 		
-		public FastMap<Integer, Long> getPlayerAllowedReEntryTimes()
+		public Map<Integer, Long> getPlayerAllowedReEntryTimes()
 		{
 			return _playerAllowedReEntryTimes;
 		}
 		
-		public L2FastList<Integer> getPlayersAllowed()
+		public List<Integer> getPlayersAllowed()
 		{
 			return _playersAllowed;
 		}
 		
-		public L2FastList<L2Character> getRaidList()
+		public List<L2Character> getRaidList()
 		{
 			return _raidList;
 		}
@@ -316,7 +314,7 @@ public class L2BossZone extends L2ZoneType
 		return _timeInvade;
 	}
 	
-	public void setAllowedPlayers(L2FastList<Integer> players)
+	public void setAllowedPlayers(List<Integer> players)
 	{
 		if (players != null)
 		{
@@ -325,7 +323,7 @@ public class L2BossZone extends L2ZoneType
 		}
 	}
 	
-	public L2FastList<Integer> getAllowedPlayers()
+	public List<Integer> getAllowedPlayers()
 	{
 		return getSettings().getPlayersAllowed();
 	}

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/taskmanager/TaskManager.java

@@ -36,6 +36,8 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javolution.util.FastList;
+
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.taskmanager.tasks.TaskBirthday;
@@ -51,7 +53,6 @@ import com.l2jserver.gameserver.taskmanager.tasks.TaskRestart;
 import com.l2jserver.gameserver.taskmanager.tasks.TaskScript;
 import com.l2jserver.gameserver.taskmanager.tasks.TaskSevenSignsUpdate;
 import com.l2jserver.gameserver.taskmanager.tasks.TaskShutdown;
-import com.l2jserver.util.L2FastList;
 
 /**
  * @author Layane
@@ -61,7 +62,7 @@ public final class TaskManager
 	protected static final Logger _log = Logger.getLogger(TaskManager.class.getName());
 	
 	private final Map<Integer, Task> _tasks = new ConcurrentHashMap<>();
-	protected final List<ExecutedTask> _currentTasks = new L2FastList<>(true);
+	protected final List<ExecutedTask> _currentTasks = new FastList<ExecutedTask>().shared();
 	
 	protected static final String[] SQL_STATEMENTS =
 	{

+ 0 - 75
L2J_Server_BETA/java/com/l2jserver/util/L2FastList.java

@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2004-2014 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.util;
-
-import java.util.Collection;
-
-import javolution.util.FastList;
-
-/**
- * A custom version of {@code FastList} with constructors that allow the constructed {@code FastList} to be shared without calling {@link FastList#shared()} method. <br>
- * @author Julian
- * @param <T>
- */
-public class L2FastList<T> extends FastList<T>
-{
-	private static final long serialVersionUID = 8354641653178203420L;
-	
-	public L2FastList()
-	{
-		this(false);
-	}
-	
-	public L2FastList(int initialCapacity)
-	{
-		this(initialCapacity, false);
-	}
-	
-	public L2FastList(Collection<? extends T> c)
-	{
-		this(c, false);
-	}
-	
-	public L2FastList(boolean shared)
-	{
-		super();
-		if (shared)
-		{
-			shared();
-		}
-	}
-	
-	public L2FastList(int initialCapacity, boolean shared)
-	{
-		super(initialCapacity);
-		if (shared)
-		{
-			shared();
-		}
-	}
-	
-	public L2FastList(Collection<? extends T> c, boolean shared)
-	{
-		super(c);
-		if (shared)
-		{
-			shared();
-		}
-	}
-}