Kaynağa Gözat

BETA: Reworking PlayerEventStatus:
* Renamed to PlayerEventHolder.
* Moved from Util package to Holder package.
* Added option to store also name and clan of player.
* Note: sitForced and kills should later be moved into seperate class with maybe few more parameters, when event engine will evolve.
* Reviewed by: Zoey76, UnAfraid

xban1x 11 yıl önce
ebeveyn
işleme
d8e17e1c77

+ 7 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -204,6 +204,7 @@ import com.l2jserver.gameserver.model.entity.TvTEvent;
 import com.l2jserver.gameserver.model.fishing.L2Fish;
 import com.l2jserver.gameserver.model.fishing.L2Fishing;
 import com.l2jserver.gameserver.model.holders.ItemHolder;
+import com.l2jserver.gameserver.model.holders.PlayerEventHolder;
 import com.l2jserver.gameserver.model.holders.SkillUseHolder;
 import com.l2jserver.gameserver.model.interfaces.IPositionable;
 import com.l2jserver.gameserver.model.itemcontainer.Inventory;
@@ -328,7 +329,6 @@ import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.Transfor
 import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
 import com.l2jserver.gameserver.util.Broadcast;
 import com.l2jserver.gameserver.util.FloodProtectors;
-import com.l2jserver.gameserver.util.PlayerEventStatus;
 import com.l2jserver.gameserver.util.Point3D;
 import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.Rnd;
@@ -770,7 +770,7 @@ public final class L2PcInstance extends L2Playable
 	public final ReentrantLock soulShotLock = new ReentrantLock();
 	
 	/** Event parameters */
-	private PlayerEventStatus eventStatus = null;
+	private PlayerEventHolder eventStatus = null;
 	
 	private byte _handysBlockCheckerEventArena = -1;
 	
@@ -3188,7 +3188,7 @@ public final class L2PcInstance extends L2Playable
 	 */
 	public void standUp()
 	{
-		if (L2Event.isParticipant(this) && getEventStatus().eventSitForced)
+		if (L2Event.isParticipant(this) && getEventStatus().isSitForced())
 		{
 			sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up...");
 		}
@@ -5463,7 +5463,7 @@ public final class L2PcInstance extends L2Playable
 				
 				if (L2Event.isParticipant(pk))
 				{
-					pk.getEventStatus().kills.add(this);
+					pk.getEventStatus().getKills().add(this);
 				}
 				
 				// announce pvp/pk
@@ -14433,15 +14433,15 @@ public final class L2PcInstance extends L2Playable
 	
 	public void setEventStatus()
 	{
-		eventStatus = new PlayerEventStatus(this);
+		eventStatus = new PlayerEventHolder(this);
 	}
 	
-	public void setEventStatus(PlayerEventStatus pes)
+	public void setEventStatus(PlayerEventHolder pes)
 	{
 		eventStatus = pes;
 	}
 	
-	public PlayerEventStatus getEventStatus()
+	public PlayerEventHolder getEventStatus()
 	{
 		return eventStatus;
 	}

+ 4 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/L2Event.java

@@ -45,13 +45,13 @@ import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
+import com.l2jserver.gameserver.model.holders.PlayerEventHolder;
 import com.l2jserver.gameserver.model.interfaces.IL2Procedure;
 import com.l2jserver.gameserver.network.serverpackets.CharInfo;
 import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
 import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
 import com.l2jserver.gameserver.network.serverpackets.UserInfo;
-import com.l2jserver.gameserver.util.PlayerEventStatus;
 
 /**
  * @since $Revision: 1.3.4.1 $ $Date: 2005/03/27 15:29:32 $ This ancient thingie got reworked by Nik at $Date: 2011/05/17 21:51:39 $ Yeah, for 6 years no one bothered reworking this buggy event engine.
@@ -69,7 +69,7 @@ public class L2Event
 	public static final Map<Integer, List<L2PcInstance>> _teams = new FastMap<>();
 	public static int _npcId = 0;
 	// public static final List<L2Npc> _npcs = new FastList<L2Npc>();
-	private static final Map<L2PcInstance, PlayerEventStatus> _connectionLossData = new FastMap<>();
+	private static final Map<L2PcInstance, PlayerEventHolder> _connectionLossData = new FastMap<>();
 	
 	public enum EventState
 	{
@@ -111,7 +111,7 @@ public class L2Event
 				{
 					continue;
 				}
-				tmp.put(player, player.getEventStatus().kills.size());
+				tmp.put(player, player.getEventStatus().getKills().size());
 			}
 		}
 		
@@ -313,7 +313,7 @@ public class L2Event
 			
 			if (player.getEventStatus() != null)
 			{
-				player.getEventStatus().restoreInits();
+				player.getEventStatus().restorePlayerStats();
 			}
 			
 			player.setEventStatus(null);

+ 102 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/holders/PlayerEventHolder.java

@@ -0,0 +1,102 @@
+/*
+ * 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.model.holders;
+
+import java.util.List;
+
+import javolution.util.FastList;
+
+import com.l2jserver.gameserver.datatables.ClanTable;
+import com.l2jserver.gameserver.model.Location;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * Player event holder, meant for restoring player after event has finished.<br>
+ * Allows you to restore following information about player:
+ * <ul>
+ * <li>Name</li>
+ * <li>Title</li>
+ * <li>Clan</li>
+ * <li>Location</li>
+ * <li>PvP Kills</li>
+ * <li>PK Kills</li>
+ * <li>Karma</li>
+ * </ul>
+ * @author Nik, xban1x
+ */
+public final class PlayerEventHolder
+{
+	private final L2PcInstance _player;
+	private final String _name;
+	private final String _title;
+	private final int _clanId;
+	private final Location _loc;
+	private final int _pvpKills;
+	private final int _pkKills;
+	private final int _karma;
+	
+	private final List<L2PcInstance> _kills;
+	private boolean _sitForced;
+	
+	public PlayerEventHolder(L2PcInstance player)
+	{
+		this(player, false);
+	}
+	
+	public PlayerEventHolder(L2PcInstance player, boolean sitForced)
+	{
+		_player = player;
+		_name = player.getName();
+		_title = player.getTitle();
+		_clanId = player.getClanId();
+		_loc = new Location(player);
+		_pvpKills = player.getPvpKills();
+		_pkKills = player.getPkKills();
+		_karma = player.getKarma();
+		_kills = new FastList<>();
+		_sitForced = sitForced;
+	}
+	
+	public void restorePlayerStats()
+	{
+		_player.setName(_name);
+		_player.setTitle(_title);
+		_player.setClan(ClanTable.getInstance().getClan(_clanId));
+		_player.teleToLocation(_loc, true);
+		_player.setPvpKills(_pvpKills);
+		_player.setPkKills(_pkKills);
+		_player.setKarma(_karma);
+		
+	}
+	
+	public void setSitForced(boolean sitForced)
+	{
+		_sitForced = sitForced;
+	}
+	
+	public boolean isSitForced()
+	{
+		return _sitForced;
+	}
+	
+	public List<L2PcInstance> getKills()
+	{
+		return _kills;
+	}
+}

+ 0 - 68
L2J_Server_BETA/java/com/l2jserver/gameserver/util/PlayerEventStatus.java

@@ -1,68 +0,0 @@
-/*
- * 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.util;
-
-import java.util.List;
-
-import javolution.util.FastList;
-
-import com.l2jserver.gameserver.instancemanager.InstanceManager;
-import com.l2jserver.gameserver.model.Location;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-
-/**
- * @author Nik
- */
-public class PlayerEventStatus
-{
-	public L2PcInstance player = null;
-	public Location initLoc = new Location(0, 0, 0);
-	public int initInstanceId = 0;
-	public int initKarma = 0;
-	public int initPvpKills = 0;
-	public int initPkKills = 0;
-	public String initTitle = "";
-	public List<L2PcInstance> kills = new FastList<>();
-	public boolean eventSitForced = false;
-	
-	public PlayerEventStatus(L2PcInstance player)
-	{
-		this.player = player;
-		initLoc = new Location(player.getX(), player.getY(), player.getZ(), player.getHeading());
-		initInstanceId = player.getInstanceId();
-		initKarma = player.getKarma();
-		initPvpKills = player.getPvpKills();
-		initPkKills = player.getPkKills();
-		initTitle = player.getTitle();
-		
-	}
-	
-	public void restoreInits()
-	{
-		player.teleToLocation(initLoc, true);
-		if ((initInstanceId > 0) && (InstanceManager.getInstance().getInstance(initInstanceId) != null))
-		{
-			player.setInstanceId(initInstanceId);
-		}
-		player.setKarma(initKarma);
-		player.setPvpKills(initPvpKills);
-		player.setPkKills(initPkKills);
-		player.setTitle(initTitle);
-	}
-}