Created
March 9, 2015 18:21
-
-
Save NiclasOlofsson/f07edb6df8de8ebc3a90 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