Forked from NiclasOlofsson/gist:f07edb6df8de8ebc3a90
Created
February 16, 2016 15:51
-
-
Save jose-vm/605bc2d435a58ea7e673 to your computer and use it in GitHub Desktop.
MiNET login command in plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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