Mods / Login Protection

Tags:
Utility QoL Tweak
Author:
Xel
Side:
Server
Created:
Jun 3rd 2022 at 10:36 PM
Last modified:
May 28th at 12:21 AM
Downloads:
3272
Follow Unfollow 56
Latest release (for Vintage Story 1.22.2, potentially outdated):
loginprotection-1.4.1.zip  1-click install

Tired of dying when logging into a server?

Login Protection prevents the player from taking damage when they join a server because the server thinks the player is ready even though their client is still loading.

Once the player moves or does anything, they are considered "active" and no longer protected. Players standing in lava or on fire will also not be protected.

There is also a single config option ProtectionTimeSeconds. If this is set to a number then the player's protection will expire that many seconds after logging in (this may be before the player can actually see anything. Make sure you set the number high enough).

 

Exposes a single serverside method to check if a player is protected or not, as well as 3 events:

var loginProtection = Api.ModLoader.GetModSystem<LoginProtectionModSystem>();
loginProtection.OnLoginProtectionStart += player => doSomething(player);
loginProtection.OnLoginProtectionStop += player => doSomething(player);
loginProtection.OnShouldProtect += player => shouldProtect(player);
if (wouldDoSomething && loginProtection.IsPlayerProtected(player)) Dont();
Full code example using reflection:
internal class YourModSystem : ModSystem
{
  private System.Func<IPlayer, bool> isPlayerProtected;

  public void InjurePlayer (IPlayer player)
  {
    if (_api.IsServerSide())
    {
      if (isPlayerProtected == null)
      {
        var loginProtection = _api.ModLoader.GetModSystem("LoginProtection.LoginProtectionModSystem");
        if (loginProtection != null)
        {
          var isPlayerProtectedMethod = loginProtection.GetType().GetMethod("IsPlayerProtected");
          isPlayerProtected = isPlayerProtectedMethod.CreateDelegate(typeof(System.Func<IPlayer, bool>), loginProtection) as System.Func<IPlayer, bool>;
        }
        else
        {
          isPlayerProtected = (IPlayer p) => false;
        }
      }
      if (!isPlayerProtected(player)))
      {
        ExplodePlayer(player);
      }
    }
  }
}

Mod Version Mod IdentifierFor Game version Downloads Released Changelog Download 1-click mod install*
1.4.1 loginprotection 82 May 28th at 12:21 AM loginprotection-1.4.1.zip 1-click install

haha whoopsie

  • check if player is currently protected before preventing their damage output
1.4.0 loginprotection 27 May 27th at 1:28 AM loginprotection-1.4.0.zip 1-click install
  • Remove protection when getting on a boat or other mountable thing
  • Remove protection when doing damage to any entity
1.3.0-pre.1 loginprotection
1.22.0 - 1.22.2
84 May 8th at 1:29 AM loginprotection-1.3.0-pre.1.zip 1-click install

Recompile for net10. I didn't test it, pls test for me. Thanks

1.2.0 loginprotection
1.18.9 - 1.18.10
1064 Sep 4th 2023 at 3:35 PM loginprotection-1.2.0.zip 1-click install
  • Disable the oxygen bar while protection is enabled
1.1.0 loginprotection
1.18.9 - 1.18.10
380 Jul 26th 2023 at 2:11 AM loginprotection-1.1.0.zip 1-click install
  • Add a config file with an option for ProtectionTimeSeconds
1.0.3 loginprotection 370 Apr 8th 2023 at 12:01 PM loginprotection-1.0.3.zip 1-click install

- recompile for 1.18

1.0.2 loginprotection 422 Jun 7th 2022 at 12:54 PM loginprotection-1.0.2.zip 1-click install

Add a new event OnShouldProtect. A delegate on this event that returns false will prevent login protection from being applied to a player

1.0.1 loginprotection 377 Jun 4th 2022 at 2:34 PM loginprotection-1.0.1.zip 1-click install
  • Added OnLoginProtectionStart and OnLoginProtectionStop events for developers
  • Protection no longer prevents healing
1.0.0 loginprotection 466 Jun 3rd 2022 at 10:39 PM Empty LoginProtection-1.0.0.dll 1-click install

16 Comments (oldest first | newest first) (threaded | flat)

AlteOgre, May 27th at 3:16 AM

After loading latest version v1.4.0, players weer no longer able to damage entities. We reverted to v1.3.0-pre1.

Screwy, May 27th at 6:12 AM
@AlteOgre: After loading latest version v1.4.0, players weer no longer able to damage entities. We reverted to v1.3.0-pre1.

I can confirm that. While this tecnically fixes the other issue mentioned earlier, it makes the game a forced pacifist run now. Makes a whole new challange hardcore survival mod out of this =D

Screwy, May 27th at 12:25 AM (modified May 27th at 4:19 AM)

Hey there! The mod works fine so far I can tell, but I think I found a small exploit:
Users on my server tend to disconnect and rejoin to make Drifters despawn.
... Ah yea, and a major exploit, which I think you should fix soon after me writing this:

Spoiler!
I guess you know about it now. Hope you can fix the new issue too.
Thalius, May 12th at 12:53 AM

Thank you for the update!!

Kyattono, May 8th at 12:55 PM

1.3.0-pre.1 seems to work fine on my 1.22 server on a launch test.

Thalius, May 7th at 2:04 PM

Needs re-compiling to NET 10 for use on VS 1.22.

Any chance on an update soon? 

berserkus, Jan 14th at 2:59 AM

tried on 1.21.6, it still works :)

Shinji170981, May 3rd 2025 at 12:30 PM

Xel would this still work with 1.20.9?
Bit hesitant to load it on a live server currently but we do have a few people with weak connection, so it would help a lot.

Thanks in advance :)

Linthiel, Mar 11th 2025 at 2:49 AM

Thalius just tested it and it is working as of 1.20.4

Thalius, Feb 25th 2025 at 9:58 PM

Is this working for 1.20.x?

UA_Shaman, Feb 4th 2024 at 5:40 PM

Tested on multiplayer server version 1.19.3, everything works. You can install and enjoy!

Marlim, Jan 20th 2024 at 5:51 PM

Will the mod be updated to 1.19?

Yskar, Sep 22nd 2023 at 7:15 AM

Could you add an 'PING' sound when the game connects or the game finished loading in single player (and pause the game)?

Xel , Sep 4th 2023 at 2:43 PM
  • as long they do not move, they can still hit stuff and maintain invulnerability - They cannot hit things, break blocks, or place blocks without losing protection
  • Please think seriously about adding a timer on rather how long the protection lasts - Already exists; see mod description
  • make it cancel invulnerability when an attack is performed by the player - Already does
  • Also, if you fell in the water and are technically not moving but your character is sinking, it should not cancel invulnerability - It doesn't, only horizontal movement cancels invulnerability
Fenvar, Sep 3rd 2023 at 8:41 PM

A lot of people like to abuse the login protection in order to be invulnerable and so as long they do not move, they can still hit stuff and maintain invulnerability. Please think seriously about adding a timer on rather how long the protection lasts or make it cancel invulnerability when an attack is performed by the player. Additionally, if you are in the invulnerability state, please make it freeze your present health and food unless you are moving/switching equipment/trying to bring your food/health back up or anything else aside from chatting to seek help in the chat window. Also, if you fell in the water and are technically not moving but your character is sinking, it should not cancel invulnerability unless the player themselves presses a button besides chatting keys. This should greatly reduce invulnerability abuse.

Mohandar, Jul 22nd 2023 at 10:07 AM

Any chance to make the protection "timed" and configurable?
(like: 30 seconds of protection, 60 seconds or so on)
Xel