// parse ./auth kick
if (args[0].equalsIgnoreCase("kick"))
{
if (!hasAdmin)
{
throw new PermissionDeniedException();
}
else if (!isLogged)
{
throw new PlayerNotFoundException();
}
else
{
ModuleAuth.hasSession.remove(name);
OutputHandler.chatConfirmation(sender, String.format("Player %s was logged out from the authentication service.", name));
OutputHandler.chatWarning(player, "You have been logged out from the authentication service. Please login again.");
return;
}
}
// parse ./auth setpass
else if (args[0].equalsIgnoreCase("setPass"))
{
if (!hasAdmin)
{
throw new PermissionDeniedException();
}
throw new WrongUsageException("/auth setpass <player> <password>");
}
// parse ./auth unregister
else if (args[0].equalsIgnoreCase("unregister"))
{
if (!hasAdmin)
{
throw new PermissionDeniedException();
}
if (PlayerPassData.getData(name) == null)
{
throw new WrongUsageException(String.format("Player %s is not registered!", name));
}
PlayerPassData.deleteData(name);
OutputHandler.chatConfirmation(sender, String.format("Player %s has been removed from the authentication service.", name));
return;
}
// ERROR! :D
else
{
throw new WrongUsageException("/auth help");
}
}
// 3 args? must be a comtmand - player - pass
else if (args.length == 3)
{
if (!ModuleAuth.hasSession.contains(sender.getPersistentID()))
{
OutputHandler.chatError(sender, "Login required. Try /auth help.");
return;
}
// parse changePass
if (args[0].equalsIgnoreCase("changepass"))
{
UUID name = sender.getPersistentID();
PlayerPassData data = PlayerPassData.getData(name);
if (data == null)
{
throw new WrongUsageException(String.format("Player %s is not registered!", name));
}
String oldpass = ModuleAuth.encrypt(args[1]);
String newPass = ModuleAuth.encrypt(args[2]);
if (args[1].equals(args[2]))
{
OutputHandler.chatConfirmation(sender, "You can't use this new password - it's the same as what was previously there.");
return;
}
if (!data.password.equals(oldpass))
{
OutputHandler.chatConfirmation(sender, "Could not change the password - your old password is wrong");
return;
}
data.password = newPass;
data.save();
OutputHandler.chatConfirmation(sender, "Password change successful.");
return;
}
// check for players.. all the rest of these should be greated than 1.
UUID name = UserIdent.getUuidByUsername(args[1]);
// check if the player is logged.
EntityPlayerMP player = UserIdent.getPlayerByMatchOrUsername(sender, args[1]);
if (player == null)
{
OutputHandler.chatWarning(sender, "A player of that name is not on the server. Doing the action anyways.");
}
// pasre setPass
if (args[0].equalsIgnoreCase("setPass"))
{
if (!hasAdmin)
{
throw new PermissionDeniedException();
}
PlayerPassData data = PlayerPassData.getData(name);
String encrypted = ModuleAuth.encrypt(args[2]);