Skip to content

Instantly share code, notes, and snippets.

@jose-vm
Forked from NiclasOlofsson/gist:f07edb6df8de8ebc3a90
Created February 16, 2016 15:51
Show Gist options
  • Save jose-vm/605bc2d435a58ea7e673 to your computer and use it in GitHub Desktop.
Save jose-vm/605bc2d435a58ea7e673 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