2015-10-30 01:13:55 +00:00
|
|
|
package cn.citycraft.AuthMe.commands;
|
2015-10-12 07:26:15 +00:00
|
|
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2015-10-30 01:13:55 +00:00
|
|
|
import cn.citycraft.AuthMe.AuthMe;
|
|
|
|
import cn.citycraft.AuthMe.cache.auth.PlayerAuth;
|
|
|
|
import cn.citycraft.AuthMe.settings.Messages;
|
|
|
|
import cn.citycraft.AuthMe.settings.Settings;
|
2015-10-12 07:26:15 +00:00
|
|
|
|
|
|
|
public class RegisterCommand implements CommandExecutor {
|
|
|
|
|
|
|
|
public PlayerAuth auth;
|
|
|
|
public AuthMe plugin;
|
2015-11-04 15:10:36 +00:00
|
|
|
private final Messages m = Messages.getInstance();
|
2015-10-12 07:26:15 +00:00
|
|
|
|
2015-11-04 15:10:36 +00:00
|
|
|
public RegisterCommand(final AuthMe plugin) {
|
2015-10-12 07:26:15 +00:00
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-04 15:10:36 +00:00
|
|
|
public boolean onCommand(final CommandSender sender, final Command cmnd, final String label, final String[] args) {
|
2015-10-12 07:26:15 +00:00
|
|
|
if (!(sender instanceof Player)) {
|
2015-12-15 11:41:34 +00:00
|
|
|
sender.sendMessage("控制台请使用 'authme register <playername> <password>' 注册玩家");
|
2015-10-12 07:26:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
final Player player = (Player) sender;
|
|
|
|
if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2)) {
|
|
|
|
m.send(player, "usage_reg");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!plugin.authmePermissible(player, "authme." + label.toLowerCase())) {
|
|
|
|
m.send(player, "no_perm");
|
|
|
|
return true;
|
|
|
|
}
|
2015-11-04 15:10:36 +00:00
|
|
|
// TODO 计划删除邮箱功能
|
|
|
|
// if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
|
|
|
// if (Settings.doubleEmailCheck) {
|
|
|
|
// if (args.length < 2 || !args[0].equals(args[1])) {
|
|
|
|
// m.send(player, "usage_reg");
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// final String email = args[0];
|
|
|
|
// if (!Settings.isEmailCorrect(email)) {
|
|
|
|
// m.send(player, "email_invalid");
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
|
|
|
// final String thePass = rand.nextString();
|
|
|
|
// plugin.management.performRegister(player, thePass, email);
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
if (args.length > 1 && Settings.getEnablePasswordVerifier) {
|
2015-10-12 07:26:15 +00:00
|
|
|
if (!args[0].equals(args[1])) {
|
|
|
|
m.send(player, "password_error");
|
|
|
|
return true;
|
|
|
|
}
|
2015-11-04 15:10:36 +00:00
|
|
|
}
|
2015-10-12 07:26:15 +00:00
|
|
|
plugin.management.performRegister(player, args[0], "");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|