瀏覽代碼

Offline trade mod. Enjoy it :)

_DS_ 16 年之前
父節點
當前提交
0ff59df708

+ 18 - 0
L2_GameServer/java/config/l2jmods.properties

@@ -196,6 +196,24 @@ EnableWarehouseSortingPrivate = False
 EnableWarehouseSortingFreight = False
 
 
+# ---------------------------------------------------------------------------
+# Offline trade/craft
+# ---------------------------------------------------------------------------
+# Option to enable or disable offline trade feature.
+# Enable -> true, Disable -> false
+OfflineTradeEnable = False
+
+# Option to enable or disable offline craft feature.
+# Enable -> true, Disable -> false
+OfflineCraftEnable = False
+
+# If set to True, name color will be changed then entering offline mode
+OfflineSetNameColor = False
+
+# Color of the name in offline mode (if OfflineSetNameColor = True)
+OfflineNameColor = 808080
+
+
 # ---------------------------------------------------------------------------
 # Mana Drugs/Potions
 # ---------------------------------------------------------------------------

+ 9 - 0
L2_GameServer/java/net/sf/l2j/Config.java

@@ -566,6 +566,10 @@ public final class Config
 	public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_CLAN;
 	public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE;
 	public static boolean L2JMOD_ENABLE_WAREHOUSESORTING_FREIGHT;
+	public static boolean OFFLINE_TRADE_ENABLE;
+	public static boolean OFFLINE_CRAFT_ENABLE;
+	public static boolean OFFLINE_SET_NAME_COLOR;
+	public static int OFFLINE_NAME_COLOR;
 	public static boolean L2JMOD_ENABLE_MANA_POTIONS_SUPPORT;
 
 
@@ -1806,6 +1810,11 @@ public final class Config
 					BANKING_SYSTEM_GOLDBARS = Integer.parseInt(L2JModSettings.getProperty("BankingGoldbarCount", "1"));
 					BANKING_SYSTEM_ADENA = Integer.parseInt(L2JModSettings.getProperty("BankingAdenaCount", "500000000"));
 
+					OFFLINE_TRADE_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineTradeEnable", "false"));
+					OFFLINE_CRAFT_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineCraftEnable", "false"));
+					OFFLINE_SET_NAME_COLOR = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineSetNameColor", "false"));
+					OFFLINE_NAME_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("OfflineNameColor", "808080"));
+
 					L2JMOD_ENABLE_MANA_POTIONS_SUPPORT = Boolean.parseBoolean(L2JModSettings.getProperty("EnableManaPotionSupport", "false"));
 				}
 				catch (Exception e)

+ 8 - 1
L2_GameServer/java/net/sf/l2j/gameserver/model/L2ClanMember.java

@@ -144,7 +144,14 @@ public class L2ClanMember
 
 	public boolean isOnline()
 	{
-		return _player != null;
+		if (_player == null)
+			return false;
+		if (_player.getClient() == null)
+			return false;
+		if (_player.getClient().isDetached())
+			return false;
+
+		return true;
 	}
 
 	/**

+ 23 - 3
L2_GameServer/java/net/sf/l2j/gameserver/network/L2GameClient.java

@@ -40,6 +40,7 @@ import net.sf.l2j.gameserver.model.L2Clan;
 import net.sf.l2j.gameserver.model.L2World;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.entity.L2Event;
+import net.sf.l2j.gameserver.model.entity.TvTEvent;
 import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket;
 import net.sf.l2j.util.EventData;
 
@@ -593,9 +594,28 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 			{
 				isDetached(true);
 				L2PcInstance player = L2GameClient.this.getActiveChar();
-				if (player != null && player.isInCombat())
+				if (player != null)
 				{
-					fast = false;
+					if (!player.isInOlympiadMode()
+							&& !player.isFestivalParticipant()
+							&& !TvTEvent.isPlayerParticipant(player.getObjectId()) && !player.isInJail())
+					{
+						if ((player.isInStoreMode() && Config.OFFLINE_TRADE_ENABLE)
+								|| (player.isInCraftMode() && Config.OFFLINE_CRAFT_ENABLE))
+						{
+							player.leaveParty();
+							if (Config.OFFLINE_SET_NAME_COLOR)
+							{
+								player.getAppearance().setNameColor(Config.OFFLINE_NAME_COLOR);
+								player.broadcastUserInfo();
+							}
+							return;
+						}
+					}
+					if (player.isInCombat())
+					{
+						fast = false;
+					}
 				}
 				cleanMe(fast);
 			}
@@ -643,7 +663,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>>
 					e.printStackTrace();
 				}
 
-				// we are going to mannually save the char bellow thus we can force the cancel
+				// we are going to manually save the char bellow thus we can force the cancel
 				if (_autoSaveInDB != null)
                 {
 				    _autoSaveInDB.cancel(true);

+ 8 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java

@@ -104,6 +104,14 @@ public final class Logout extends L2GameClientPacket
 		}
 
 		TvTEvent.onLogout(player);
+		
+		if ((player.isInStoreMode() && Config.OFFLINE_TRADE_ENABLE)
+				|| (player.isInCraftMode() && Config.OFFLINE_CRAFT_ENABLE))
+		{
+			player.closeNetConnection();
+			return;
+		}
+
 		RegionBBSManager.getInstance().changeCommunityBoard();
 
 		player.deleteMe();

+ 6 - 0
L2_GameServer/java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java

@@ -105,6 +105,12 @@ public final class RequestJoinParty extends L2GameClientPacket
 			requestor.sendMessage("Player is in Jail");
 			return;
 		}
+		
+		if (target.getClient().isDetached())
+		{
+			requestor.sendMessage("Player is in offline mode.");
+			return;
+		}
 
         if (target.isInOlympiadMode() || requestor.isInOlympiadMode())
             return;