Browse Source

BETA: Core-part for [DP10132]
* Patch by: xban1x

St3eT 11 years ago
parent
commit
f0ecc2e135

+ 1 - 1
L2J_Server_BETA/dist/game/config/GrandBoss.properties

@@ -3,7 +3,7 @@
 # ---------------------------------------------------------------------------
 
 # Delay of appearance time of Antharas. Value is minute. Range 3-60
-AntharasWaitTime = 30
+AntharasWaitTime = 20
 
 # Interval time of Antharas. Value is hour. Range 1-480
 IntervalOfAntharasSpawn = 264

+ 10 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/GrandBossManager.java

@@ -31,13 +31,16 @@ import java.util.logging.Logger;
 import javolution.util.FastMap;
 
 import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.datatables.NpcTable;
+import com.l2jserver.gameserver.instancemanager.tasks.GrandBossManagerStoreTask;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.Location;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
 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;
 
@@ -47,7 +50,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
 /**
  * @author DaRkRaGe Revised by Emperorc
  */
-public final class GrandBossManager
+public final class GrandBossManager implements IStorable
 {
 	// SQL queries
 	private static final String DELETE_GRAND_BOSS_LIST = "DELETE FROM grandboss_list";
@@ -117,6 +120,7 @@ public final class GrandBossManager
 		{
 			_log.log(Level.WARNING, "Error while initializing GrandBossManager: " + e.getMessage(), e);
 		}
+		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new GrandBossManagerStoreTask(), 5 * 60 * 1000, 5 * 60 * 1000);
 	}
 	
 	/**
@@ -298,7 +302,8 @@ public final class GrandBossManager
 		updateDb(bossId, false);
 	}
 	
-	private void storeToDb()
+	@Override
+	public boolean storeMe()
 	{
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement delete = con.prepareStatement(DELETE_GRAND_BOSS_LIST))
@@ -371,7 +376,9 @@ public final class GrandBossManager
 		catch (SQLException e)
 		{
 			_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't store grandbosses to database:" + e.getMessage(), e);
+			return false;
 		}
+		return true;
 	}
 	
 	private void updateDb(int bossId, boolean statusOnly)
@@ -425,7 +432,7 @@ public final class GrandBossManager
 	 */
 	public void cleanUp()
 	{
-		storeToDb();
+		storeMe();
 		
 		_bosses.clear();
 		_storedInfo.clear();

+ 34 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/tasks/GrandBossManagerStoreTask.java

@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2004-2013 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.gameserver.instancemanager.tasks;
+
+import com.l2jserver.gameserver.instancemanager.GrandBossManager;
+
+/**
+ * @author xban1x
+ */
+public class GrandBossManagerStoreTask implements Runnable
+{
+	@Override
+	public void run()
+	{
+		GrandBossManager.getInstance().storeMe();
+	}
+	
+}