Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into commands-refactor

Conflicts:
	src/main/java/fr/xephi/authme/command/CommandUtils.java
	src/main/java/fr/xephi/authme/command/executable/captcha/CaptchaCommand.java
This commit is contained in:
ljacqu
2015-12-17 22:32:26 +01:00
38 changed files with 375 additions and 182 deletions
@@ -1,7 +1,12 @@
package fr.xephi.authme.command;
import com.google.common.collect.Lists;
import fr.xephi.authme.util.CollectionUtils;
import fr.xephi.authme.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
public final class CommandUtils {
public static int getMinNumberOfArguments(CommandDescription command) {
@@ -23,10 +28,20 @@ public final class CommandUtils {
* the items ["authme", "register", "player"] it will return "authme register player".
*
* @param labels The labels to format
*
* @return The space-separated labels
*/
public static String labelsToString(Iterable<String> labels) {
return StringUtils.join(" ", labels);
}
public static String constructCommandPath(CommandDescription command) {
List<String> labels = new ArrayList<>();
CommandDescription currentCommand = command;
while (currentCommand != null) {
labels.add(currentCommand.getLabels().get(0));
currentCommand = currentCommand.getParent();
}
return "/" + labelsToString(Lists.reverse(labels));
}
}
@@ -52,7 +52,7 @@ public class UnregisterAdminCommand extends ExecutableCommand {
}
// Unregister the player
Player target = Bukkit.getPlayer(playerNameLowerCase);
Player target = Utils.getPlayer(playerNameLowerCase);
PlayerCache.getInstance().removePlayer(playerNameLowerCase);
Utils.setGroup(target, Utils.GroupType.UNREGISTERED);
if (target != null && target.isOnline()) {
@@ -68,11 +68,9 @@ public class UnregisterAdminCommand extends ExecutableCommand {
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTaskId(
scheduler.runTaskAsynchronously(plugin,
new MessageTask(plugin, playerNameLowerCase, m.retrieve(MessageKey.REGISTER_MESSAGE), interval)));
if (Settings.applyBlindEffect)
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
target.setWalkSpeed(0.0f);
target.setFlySpeed(0.0f);
if (Settings.applyBlindEffect) {
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,
Settings.getRegistrationTimeout * 20, 2));
}
m.send(target, MessageKey.UNREGISTERED_SUCCESS);
@@ -57,9 +57,7 @@ public class CaptchaCommand extends ExecutableCommand {
plugin.cap.remove(playerNameLowerCase);
String randStr = new RandomString(Settings.captchaLength).nextString();
plugin.cap.put(playerNameLowerCase, randStr);
for (String s : m.retrieve(MessageKey.CAPTCHA_WRONG_ERROR)) {
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(playerNameLowerCase)));
}
m.send(player, MessageKey.CAPTCHA_WRONG_ERROR, plugin.cap.get(playerNameLowerCase));
return;
}