Skip to content

Instantly share code, notes, and snippets.

@NiclasOlofsson
Created March 9, 2015 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NiclasOlofsson/f07edb6df8de8ebc3a90 to your computer and use it in GitHub Desktop.
Save NiclasOlofsson/f07edb6df8de8ebc3a90 to your computer and use it in GitHub Desktop.
MiNET login command in plugin.
[Plugin("CoreCommands", "The core commands for MiNET", "1.0", "MiNET Team")]
public class CoreCommands : Plugin
{
[Command]
public void Login(Player player, string password)
{
UserManager<User> userManager = player.Server.UserManager;
if (userManager != null)
{
if (player.Username == null) return;
User user = userManager.FindByName(player.Username);
if (user == null)
{
user = new User(player.Username);
if (!userManager.Create(user, password).Succeeded) return;
}
if (userManager.CheckPassword(user, password))
{
player.SendMessage("Login successful");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment