Mods / Login Protection

Category: #QoL #Tweak #Utility
Author: Xel
Side: Server
Created: Jun 3rd 2022 at 10:36 PM
Last modified: Sep 4th 2023 at 3:35 PM
Downloads: 2022
Follow Unfollow 32

Latest file for Various v1.18.x:
loginprotection-1.2.0.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);
      }
    }
  }
}

 

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v1.2.0 530 Sep 4th 2023 at 3:35 PM Show loginprotection-1.2.0.zip Install now
v1.1.0 285 Jul 26th 2023 at 2:11 AM Show loginprotection-1.1.0.zip Install now
v1.0.3 291 Apr 8th 2023 at 12:01 PM Show loginprotection-1.0.3.zip Install now
v1.0.2 347 Jun 7th 2022 at 12:54 PM Show loginprotection-1.0.2.zip Install now
v1.0.1 290 Jun 4th 2022 at 2:34 PM Show loginprotection-1.0.1.zip Install now
v1.0.0 279 Jun 3rd 2022 at 10:39 PM Show LoginProtection-1.0.0.dll Install now

6 Comments (oldest first | newest first)

💬 UA_Shaman, Feb 4th at 5:40 PM

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

💬 Marlim, Jan 20th 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)?

💬 XelAuthor, 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
💬 Ryuu, 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

(edit comment delete)