diff --git a/pom.xml b/pom.xml index aa3ce278..d51671ab 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - 4.0.0 diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java index 5dbdaf8d..269f5573 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verify.java @@ -15,41 +15,71 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.ONLY_IN_GAME) -@CommandParameters(description = "Sends a verification code to the player, or the player can input the sent code.", usage = "/ [code]") +@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH) +@CommandParameters(description = "Sends a verification code to the player, or the player can input the sent code.", usage = "/ >") public class Command_verify extends FreedomCommand { - @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!plugin.dc.enabled) { msg("The Discord verification system is currently disabled", ChatColor.RED); return true; } - if (!plugin.al.isAdminImpostor(playerSender) && !plugin.pv.isPlayerImpostor(playerSender)) - { - msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED); - return true; - } - String discordId = ""; - - if (plugin.al.isAdminImpostor(playerSender)) + if (args.length == 1 && plugin.al.isAdmin(playerSender)) { - Admin admin = plugin.al.getEntryByName(playerSender.getName()); - if (admin.getDiscordID() == null) + final Player player = getPlayer(args[0]); + if (player == null && playerSender == null) { - msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED); + msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED); return true; } - discordId = admin.getDiscordID(); + if (!plugin.pv.isPlayerImpostor(player)) + { + msg("That player is not an impostor."); + return true; + } + FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), true); + player.setOp(true); + player.sendMessage(YOU_ARE_OP); + if (plugin.pl.getPlayer(player).getFreezeData().isFrozen()) + { + plugin.pl.getPlayer(player).getFreezeData().setFrozen(false); + msg("You have been unfrozen."); + } + plugin.pv.verifyPlayer(player); + plugin.rm.updateDisplay(player); + return true; } else { + if (senderIsConsole) + { + msg("/verify ", ChatColor.WHITE); + return true; + } + if (!plugin.pv.isPlayerImpostor(playerSender) && !plugin.al.isAdminImpostor(playerSender)) + { + msg("You are not an impostor, therefore you do not need to verify.", ChatColor.RED); + return true; + } + + String discordId = ""; + + if (plugin.al.isAdminImpostor(playerSender)) + { + Admin admin = plugin.al.getEntryByName(playerSender.getName()); + if (admin.getDiscordID() == null) + { + msg("You do not have a Discord account linked to your Minecraft account, please verify the manual way.", ChatColor.RED); + return true; + } + discordId = admin.getDiscordID(); + } + if (plugin.pv.isPlayerImpostor(playerSender)) { if (plugin.pv.getVerificationPlayer(playerSender).getDiscordId() == null) @@ -59,41 +89,37 @@ public class Command_verify extends FreedomCommand } discordId = plugin.pv.getVerificationPlayer(playerSender).getDiscordId(); } - } - if (args.length < 1) - { - String code = ""; - Random random = new Random(); - for (int i = 0; i < 10; i++) + if (args.length < 1) { - code += random.nextInt(10); - } - Discord.VERIFY_CODES.add(code); - Discord.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete(); - msg("A verification code has been sent to your account, please copy the code and run /verify ", ChatColor.GREEN); - } - else - { - String code = args[0]; - if (!Discord.VERIFY_CODES.contains(code)) - { - msg("You have entered an invalid verification code", ChatColor.RED); - return true; + String code = ""; + Random random = new Random(); + for (int i = 0; i < 10; i++) + { + code += random.nextInt(10); + } + Discord.VERIFY_CODES.add(code); + Discord.bot.getUserById(discordId).openPrivateChannel().complete().sendMessage("A user with the IP `" + Ips.getIp(playerSender) + "` has sent a verification request. Please run the following in-game command: `/verify " + code + "`").complete(); + msg("A verification code has been sent to your account, please copy the code and run /verify ", ChatColor.GREEN); } else { + String code = args[0]; + if (!Discord.VERIFY_CODES.contains(code)) + { + msg("You have entered an invalid verification code", ChatColor.RED); + return true; + } + if (plugin.al.isAdminImpostor(playerSender)) { Admin admin = plugin.al.getEntryByName(playerSender.getName()); Discord.VERIFY_CODES.remove(code); FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD); FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Readding " + admin.getName() + " to the admin list", true); - if (playerSender != null) - { - admin.setName(playerSender.getName()); - admin.addIp(Ips.getIp(playerSender)); - } + + admin.setName(playerSender.getName()); + admin.addIp(Ips.getIp(playerSender)); if (!plugin.mbl.isMasterBuilder(playerSender)) { @@ -109,11 +135,8 @@ public class Command_verify extends FreedomCommand if (masterBuilder != null) { - if (playerSender != null) - { - masterBuilder.setName(playerSender.getName()); - masterBuilder.addIp(Ips.getIp(playerSender)); - } + masterBuilder.setName(playerSender.getName()); + masterBuilder.addIp(Ips.getIp(playerSender)); masterBuilder.setLastLogin(new Date()); @@ -127,10 +150,6 @@ public class Command_verify extends FreedomCommand plugin.al.save(); plugin.al.updateTables(); plugin.rm.updateDisplay(playerSender); - if (playerSender != null) - { - plugin.rm.updateDisplay(playerSender); - } playerSender.setOp(true); msg(YOU_ARE_OP); final FPlayer fPlayer = plugin.pl.getPlayer(playerSender); @@ -139,15 +158,14 @@ public class Command_verify extends FreedomCommand fPlayer.getFreezeData().setFrozen(false); msg("You have been unfrozen."); } + return true; } - else + + if (plugin.pv.isPlayerImpostor(playerSender)) { final FPlayer fPlayer = plugin.pl.getPlayer(playerSender); FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD); - if (playerSender != null) - { - plugin.rm.updateDisplay(playerSender); - } + plugin.rm.updateDisplay(playerSender); playerSender.setOp(true); msg(YOU_ARE_OP); if (fPlayer.getFreezeData().isFrozen()) @@ -156,9 +174,9 @@ public class Command_verify extends FreedomCommand msg("You have been unfrozen."); } plugin.pv.verifyPlayer(playerSender); + return true; } } - return true; } return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifyplayer.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifyplayer.java deleted file mode 100644 index fda7cc06..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifyplayer.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.FUtil; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Manually verifies a player", usage = "/ ") -public class Command_verifyplayer extends FreedomCommand -{ - - @Override - public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length == 0) - { - return false; - } - final Player player = getPlayer(args[0]); - if (player == null) - { - msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED); - return true; - } - if (!plugin.pv.isPlayerImpostor(player)) - { - msg("That player is not an impostor."); - return true; - } - FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), true); - plugin.pv.verifyPlayer(player); - plugin.rm.updateDisplay(player); - - return true; - } -} \ No newline at end of file