Jump to content

Recommended Posts

Posted

Hello Everyone i found this Offline Trader/Crafter for Interlude Only and i wanna share it with you.

Here is the Code:

 

    Index: java/config/l2jmods.properties
    ===================================================================
    --- java/config/l2jmods.properties   (revision 4)
    +++ java/config/l2jmods.properties   (working copy)
    @@ -132,3 +132,18 @@
    # ex.: 1;2;3;4;5;6
    # no ";" at the start or end
    TvTEventDoorsCloseOpenOnStartEnd =
    +
    +# ============================================================
    +# OFFLINE TRADE & CRAFT
    +# ============================================================
    +# Enable or Disable Offline Trade & Craft
    +AllowOfflineTrade = true
    +AllowOfflineCraft = true
    +
    +# This option sets the target color
    +# Use true/false to enable color
    +# Default: none
    +OfflineTargetColor = true
    +
    +# Requires OfflineTargetColor, Trade/Craft Configs enabled
    +OfflineColor = FF00FF
    \ No newline at end of file
    Index: java/net/sf/l2j/Config.java
    ===================================================================
    --- java/net/sf/l2j/Config.java   (revision 4)
    +++ java/net/sf/l2j/Config.java   (working copy)
    @@ -882,6 +882,11 @@
         public static boolean L2JMOD_WEDDING_FORMALWEAR;
         public static int L2JMOD_WEDDING_DIVORCE_COSTS;
     
    +    public static boolean ALLOW_OFFLINE_TRADE;
    +    public static boolean ALLOW_OFFLINE_CRAFT;
    +    public static boolean OFFLINE_TARGET_COLOR;
    +    public static int OFFLINE_COLOR;
    +   
         // Packet information
         /** Count the a-beep-t of packets per minute ? */
         public static boolean  COUNT_PACKETS           = false;
    @@ -1859,6 +1864,11 @@
                     L2JMOD_WEDDING_FORMALWEAR               = Boolean.parseBoolean(L2JModSettings.getProperty("WeddingFormalWear", "True"));
                     L2JMOD_WEDDING_DIVORCE_COSTS            = Integer.parseInt(L2JModSettings.getProperty("WeddingDivorceCosts", "20"));
     
    +                ALLOW_OFFLINE_TRADE = Boolean.parseBoolean(L2JModSettings.getProperty("AllowOfflineTrade", "false"));
    +                ALLOW_OFFLINE_CRAFT = Boolean.parseBoolean(L2JModSettings.getProperty("AllowOfflineCraft", "false"));
    +                OFFLINE_TARGET_COLOR = Boolean.parseBoolean(L2JModSettings.getProperty("OfflineTargetColor", "false"));
    +                OFFLINE_COLOR = Integer.decode("0x" + L2JModSettings.getProperty("OfflineColor", "FFFFFF"));
    +               
                     if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
                     {
                         TVT_EVENT_ENABLED = false;
    Index: java/net/sf/l2j/gameserver/clientpackets/Logout.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/clientpackets/Logout.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/clientpackets/Logout.java   (working copy)
    @@ -106,6 +106,13 @@
          }
     
          TvTEvent.onLogout(player);
    +      
    +      if ((player.isInStoreMode() && Config.ALLOW_OFFLINE_TRADE) || (player.isInCraftMode() && Config.ALLOW_OFFLINE_CRAFT))
    +      {
    +         player.closeNetConnection();
    +         return;
    +      }
    +      
          RegionBBSManager.getInstance().changeCommunityBoard();
     
          player.deleteMe();
    Index: java/net/sf/l2j/gameserver/clientpackets/RequestJoinParty.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/clientpackets/RequestJoinParty.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/clientpackets/RequestJoinParty.java   (working copy)
    @@ -96,6 +96,12 @@
             return;
          }
     
    +      if (target.getClient().isDetached())
    +      {
    +          requestor.sendMessage("Player is in offline mode.");
    +          return;
    +      }
    +      
             if (target.isInOlympiadMode() || requestor.isInOlympiadMode())
                 return;
     
    Index: java/net/sf/l2j/gameserver/clientpackets/Say2.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/clientpackets/Say2.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/clientpackets/Say2.java   (working copy)
    @@ -166,6 +166,13 @@
                if (receiver != null &&
                      !BlockList.isBlocked(receiver, activeChar))
                {
    +               
    +               if (receiver.getClient().isDetached())
    +               {
    +                   activeChar.sendMessage("Player is in offline mode.");
    +                   return;
    +               }
    +               
                   if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
                     {
                             activeChar.sendMessage("Player is in jail.");
    Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEditChar.java   (working copy)
    @@ -34,6 +34,7 @@
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
    import net.sf.l2j.gameserver.model.base.ClassId;
    +import net.sf.l2j.gameserver.network.L2GameClient;
    import net.sf.l2j.gameserver.network.SystemMessageId;
    import net.sf.l2j.gameserver.serverpackets.CharInfo;
    import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
    @@ -658,10 +659,26 @@
        */
       private void findCharactersPerIp(L2PcInstance activeChar, String IpAdress) throws IllegalArgumentException
       {
    -      if (!IpAdress.matches("^(?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))$"))
    -         throw  new IllegalArgumentException("Malformed IPv4 number");
    +      //if (!IpAdress.matches("^(?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))$"))
    +      //   throw  new IllegalArgumentException("Malformed IPv4 number");
    +      
    +      boolean findDisconnected = false;
    +
    +      if (IpAdress.equals("disconnected"))
    +      {
    +         findDisconnected = true;
    +      }
    +      else
    +      {
    +         if (!IpAdress.matches("^(?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))$"))
    +            throw new IllegalArgumentException("Malformed IPv4 number");
    +      }
    +      
          Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers();
          L2PcInstance[] players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
    +      
    +      L2GameClient client;
    +      
          int CharactersFound = 0;
          String name,ip="0.0.0.0";
          TextBuilder replyMSG = new TextBuilder();
    @@ -669,13 +686,35 @@
          adminReply.setFile("data/html/admin/ipfind.htm");
          for (int i = 0; i < players.length; i++)
          {
    -         ip=players[i].getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
    -         if (ip.equals(IpAdress))
    -         {
    -            name = players[i].getName();
    -            CharactersFound = CharactersFound+1;
    -            replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_character_list "+name+"\">"+name+"</a></td><td width=110>" + players[i].getTemplate().className + "</td><td width=40>"+players[i].getLevel()+"</td></tr>");
    +         //ip=players[i].getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
    +         //if (ip.equals(IpAdress))
    +         client = activeChar.getClient();
    +         if (client.isDetached()){
    +            //name = players[i].getName();
    +            //CharactersFound = CharactersFound+1;
    +            //replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_character_list "+name+"\">"+name+"</a></td><td width=110>" + players[i].getTemplate().className + "</td><td width=40>"+players[i].getLevel()+"</td></tr>");
    +            if (!findDisconnected)
    +            {
    +                continue;
    +            }
             }
    +         else
    +             {
    +             if (findDisconnected)
    +             {
    +             continue;
    +             }
    +             else
    +             {
    +             ip=players[i].getClient().getConnection().getSocketChannel().socket().getInetAddress().getHostAddress();
    +             if (!ip.equals(IpAdress))
    +             continue;
    +             }
    +             }
    +             name = activeChar.getName();
    +             CharactersFound = CharactersFound + 1;
    +             replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_character_list " + name + "\">" + name + "</a></td><td width=110>" + activeChar.getTemplate().className + "</td><td width=40>" + activeChar.getLevel() + "</td></tr>");
    +         
             if (CharactersFound > 20)
                break;
          }
    Index: java/net/sf/l2j/gameserver/model/L2ClanMember.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/L2ClanMember.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/model/L2ClanMember.java   (working copy)
    @@ -120,7 +120,16 @@
     
       public boolean isOnline()
       {
    -      return _player != null;
    +      //return _player != null;
    +      if (_player == null)
    +          return false;
    +      if (_player.getClient() == null)
    +          return false;
    +      if (_player.getClient().isDetached())
    +          return false;
    +      
    +      return true;
    +      
       }
     
       /**
    Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
    @@ -3342,7 +3342,18 @@
       {
          if (_client != null)
          {
    -         _client.close(new LeaveWorld());
    +         //_client.close(new LeaveWorld());
    +         if (_client.isDetached())
    +         {
    +             _client.cleanMe(true);
    +         }
    +         else
    +         {
    +             if (!_client.getConnection().isClosed())
    +             {
    +                _client.close(new LeaveWorld());
    +             }
    +         }
          }
       }
     
    Index: java/net/sf/l2j/gameserver/network/L2GameClient.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/L2GameClient.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/network/L2GameClient.java   (working copy)
    @@ -39,6 +39,7 @@
    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.serverpackets.L2GameServerPacket;
    import net.sf.l2j.gameserver.serverpackets.UserInfo;
    import net.sf.l2j.util.EventData;
    @@ -77,13 +78,16 @@
     
       // Task
       protected /*final*/ ScheduledFuture _autoSaveInDB;
    -
    +   protected ScheduledFuture<?> _cleanupTask = null;
    +   
       // Crypt
       public GameCrypt crypt;
     
       // Flood protection
       public byte packetsSentInSec = 0;
       public int packetsSentStartTick = 0;
    +   
    +   private boolean _isDetached = false;
     
       public L2GameClient(MMOConnection<L2GameClient> con)
       {
    @@ -179,9 +183,21 @@
     
       public void sendPacket(L2GameServerPacket gsp)
       {
    +      if (_isDetached) return;
    +      
          getConnection().sendPacket(gsp);
          gsp.runImpl();
       }
    +   
    +   public boolean isDetached()
    +   {
    +      return _isDetached;
    +   }
    +   
    +   public void isDetached(boolean b)
    +   {
    +      _isDetached = b;
    +   }
     
       public L2PcInstance markToDeleteChar(int charslot) throws Exception
       {
    @@ -225,6 +241,13 @@
           return null;
       }
     
    +   @Override
    +   public void closeNow()
    +   {
    +       super.getConnection().close(null);
    +       cleanMe(true);
    +   }
    +   
       public L2PcInstance deleteChar(int charslot) throws Exception
       {
          //have to make sure active character must be nulled
    @@ -518,17 +541,82 @@
          }
       }
     
    -   class DisconnectTask implements Runnable
    -   {
    +    class DisconnectTask implements Runnable
    +    {
     
    -      /**
    -       * @see java.lang.Runnable#run()
    -       */
    -      public void run()
    -      {
    -         try
    -         {
    -            // Update BBS
    +       /**
    +        * @see java.lang.Runnable#run()
    +        */
    +       public void run()
    +       {
    +          boolean fast = true;
    +
    +          try
    +          {
    +             isDetached(true);
    +
    +             L2PcInstance player = L2GameClient.this.getActiveChar();
    +             if (player != null)
    +             {
    +                if (!player.isInOlympiadMode() && player.isInsidePeaceZone(player) && !player.isInDuel() &&
    +                      !player.getParty().isInDimensionalRift() && !player.isFestivalParticipant() &&
    +                      !player.atEvent && !player.isInJail())
    +                {
    +                   if ((player.isInStoreMode() && Config.ALLOW_OFFLINE_TRADE) || (player.isInCraftMode() && Config.ALLOW_OFFLINE_CRAFT))
    +                   {
    +                      player.leaveParty();
    +                      if (Config.OFFLINE_TARGET_COLOR)
    +                      {
    +                         player.getAppearance().setNameColor(Config.OFFLINE_COLOR);
    +                         player.broadcastUserInfo();
    +                      }
    +                      
    +                      return;
    +                   }
    +                }
    +                if (player.isInCombat())
    +                {
    +                   fast = false;
    +                }
    +             }
    +             cleanMe(fast);
    +          }
    +          catch (Exception e1)
    +          {
    +             _log.warning("Error while disconnecting client.");
    +          }
    +       }
    +    }
    +
    +    public void cleanMe(boolean fast)
    +    {
    +       try
    +       {
    +          synchronized(this)
    +          {
    +             if (_cleanupTask == null)
    +             {
    +                _cleanupTask = ThreadPoolManager.getInstance().scheduleGeneral(new CleanupTask(), fast ? 5 : 15000L);
    +             }
    +          }
    +       }
    +       catch (Exception e1)
    +       {
    +          _log.warning("Error during cleanup.");
    +       }
    +    }
    +
    +
    +    class CleanupTask implements Runnable
    +    {
    +       /**
    +        * @see java.lang.Runnable#run()
    +        */
    +       public void run()
    +       {
    +          try
    +          {
    +             // Update BBS
                try
                {
                   RegionBBSManager.getInstance().changeCommunityBoard();
    @@ -555,8 +643,14 @@
                       {
                          player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
                       }
    -               // notify the world about our disconnect
    -               player.deleteMe();
    +                  
    +                   // to prevent call cleanMe() again
    +                  
    +                   if(isDetached()){
    +                      isDetached(false);
    +                   }else
    +                      // notify the world about our disconnect
    +                      player.deleteMe();
     
                   try
                       {
    Index: java/net/sf/l2j/gameserver/network/L2GamePacketHandler.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/L2GamePacketHandler.java   (revision 4)
    +++ java/net/sf/l2j/gameserver/network/L2GamePacketHandler.java   (working copy)
    @@ -49,6 +49,9 @@
       // implementation
       public ReceivablePacket<L2GameClient> handlePacket(ByteBuffer buf, L2GameClient client)
       {
    +      if (client.isDetached())
    +          return null;
    +      
          int opcode = buf.get() & 0xFF;
     
          ReceivablePacket<L2GameClient> msg = null;

 

Credits By sk0rpi0n 

  • 2 months later...
  • 2 weeks later...
Posted

missing a lot of things to consider for polishing this code, for example with this code I had problems trying to log a trade offline but I modify multiple files to solve this problem and onother  when I go in after trade off no logging of where I had left it. but i can fix it so this is a great share dude :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Posts

    • @Mobius I only asked you one question! All your previous versions are sh*t and the last version is the best ? Because this is what you said.
    • Close that LOLserver. And change name to L2Wipe&Money.
    • Open Beta January 17th & 21:00 UTC +2 Launch Date January 24th & 21:00 UTC +2 Click Here to Explore Vanilla Gracia Final Low-Rate Server. Join our Discord Community     Following the success of our Vanilla project, we decided to launch it again as Last PlayINERA’s Server! Core Settings *Vanilla will have Strict Botting & Client Limitation Rules and Chronicle Progression from Gracia Final to Gracia Epilogue to H5 in Long term! XP: x4 SP: x4 Adena: x2 Drop: x2 Spoil: x3 Manor: x0.4 (60% reduction) - Festive sweeper enabled! Seal Stones: x2 Herbs: x1 Safe Enchant: +3 Maximum Enchant: Retail Enchant Rate: Dynamic General Settings Auto-loot Can be toggled Buffs Adventurer Guide buffs are free, retail level limit removed. Buff Slots: 20 (+ 4) Summon buffs will remain on re-summoning & on death while Noblesse blessing is applied! (Olympiad excluded) Pet buffs will be saved on relog but not during summon/unsummon. Event Buffer [NEW] Event Buffer is enabled and will spawn randomly between 18:00 ~ 23:00 in Giran for 10 minutes, it will apply Farm Only buffs that are cancelled in PvP, Siege / Epic PvP zones & while in a chaotic state! Duration: 1-hour! Territory Wars every two weeks on Saturday. Castle sieges every two weeks on Sunday Class Transfer 1st Class Transfer: Available for purchase with either Adena or iCoin 2nd Class Transfer: Available for purchase with either Adena or iCoin 3rd Class Transfer: Quest or iCoin (the 3rd class transfer will become available for purchase with iCoin as soon as someone has entered the Hall of Fame for completing the 3rd class transfer quest for the class in question) Hellbound Hellbound Lv. 0-6: ATOD x1 Hellbound Lv. 7-12: ATOD x2 Tiat & Ekimus will become available at Stage 12 Hellbound can only be leveled up by killing monsters. No quests or raids are needed To open Hellbound, a party must kill Baylor in the Crystal Caverns The following items are now tradable: Ancient Tome of the Demon  Hidden First Page  Hidden Second Page  Demon Contract Fragment INERA Hub Library Clan Recruitment System Options Services Milestone Rewards Earn rewards for reaching various daily/one-time goals Client Limit: 1 (+1 with Standard Premium) Shift + Click Information on Monsters SP are required to learn new skills Offline shops Lasts for 15 days Olympiad Olympiad period: 1st and 15th day of the month (14th & Last day of month is the last day) 3 Vs. 3 match disabled Class-based matches will be held over the weekends One registration per HWID (PC) Minimum participants: 9 Party Matching System Earn bonuses for finding a group via the Party Matching system Vote Reward System World Chat No limits for first day! Available from level 20 Raid Bosses Epic Raid Boss zones will turn into a PvP zone while the Epic Raid Boss is alive ( + means Random) Server will start with all grand raids dead. Normal Raids: 12h (+6 hours random). Subclass raids, respawn 12h (+6 hours random). Noblesse Barakiel 12h (+6 hours random, PvP zone). Anakim & Lilith are static 24 hours respawn. Queen Ant: 24 hours (+2 hours random). Core: 40 hours (+2 hours random). Orfen: 32 hours (+2 hours random). Antharas Respawn: 8 Days. Randomly spawns at 19:00 ~ 21:00 Boosted to level 83 on Hellbound stage 7. Valakas Respawn: 10 Days. Randomly spawns at 19:00 ~ 21:00 Baium Respawn: 5 Days. Randomly spawns at 21:00 ~ 23:00 Boosted to level 83 on Hellbound stage 7. Frintezza Respawn: 2 Days. Randomly spawns at 21:00 ~ 23:00 Instanced Zaken Zaken (Day): Monday, Wednesday, Friday at 6:30. Zaken (Day): 9 players, LvL 55-65, 1hr max. Zaken (Night): Wednesday at 6:30 Zaken (Night): 18-45 players, LvL 55-65, 6hr max. Tiat: Saturday at 6:30, 18-36 players, 2 hrs max. Boosted to level 85. Ekimus: 24h at 6:30, 18-27 players, 1hr max. Tully’s Workshop (Darion & Tully): 24h +-1h. Tower of Naia (Beleth): 5 days, 18 min. & 36 max.
  • Topics

×
×
  • Create New...