mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
merge /verifyplayer into /verify (#113)
* Spelling error and addition of forgotten checks * Fix tag nyan * this is what happens when you don't sleep for 2 days * d * Merge /verifyplayer into /verify
This commit is contained in:
parent
533e7892cc
commit
f3baf37279
2
pom.xml
2
pom.xml
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -15,41 +15,71 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.ONLY_IN_GAME)
|
@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 = "/<command> [code]")
|
@CommandParameters(description = "Sends a verification code to the player, or the player can input the sent code.", usage = "/<command> <code | <playername>>")
|
||||||
public class Command_verify extends FreedomCommand
|
public class Command_verify extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!plugin.dc.enabled)
|
if (!plugin.dc.enabled)
|
||||||
{
|
{
|
||||||
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
msg("The Discord verification system is currently disabled", ChatColor.RED);
|
||||||
return true;
|
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 (args.length == 1 && plugin.al.isAdmin(playerSender))
|
||||||
|
|
||||||
if (plugin.al.isAdminImpostor(playerSender))
|
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
final Player player = getPlayer(args[0]);
|
||||||
if (admin.getDiscordID() == null)
|
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;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
msg("/verify <playername>", 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.isPlayerImpostor(playerSender))
|
||||||
{
|
{
|
||||||
if (plugin.pv.getVerificationPlayer(playerSender).getDiscordId() == null)
|
if (plugin.pv.getVerificationPlayer(playerSender).getDiscordId() == null)
|
||||||
@ -59,41 +89,37 @@ public class Command_verify extends FreedomCommand
|
|||||||
}
|
}
|
||||||
discordId = plugin.pv.getVerificationPlayer(playerSender).getDiscordId();
|
discordId = plugin.pv.getVerificationPlayer(playerSender).getDiscordId();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
|
||||||
String code = "";
|
|
||||||
Random random = new Random();
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
{
|
||||||
code += random.nextInt(10);
|
String code = "";
|
||||||
}
|
Random random = new Random();
|
||||||
Discord.VERIFY_CODES.add(code);
|
for (int i = 0; i < 10; i++)
|
||||||
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 <code>", ChatColor.GREEN);
|
code += random.nextInt(10);
|
||||||
}
|
}
|
||||||
else
|
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();
|
||||||
String code = args[0];
|
msg("A verification code has been sent to your account, please copy the code and run /verify <code>", ChatColor.GREEN);
|
||||||
if (!Discord.VERIFY_CODES.contains(code))
|
|
||||||
{
|
|
||||||
msg("You have entered an invalid verification code", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
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))
|
if (plugin.al.isAdminImpostor(playerSender))
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
Admin admin = plugin.al.getEntryByName(playerSender.getName());
|
||||||
Discord.VERIFY_CODES.remove(code);
|
Discord.VERIFY_CODES.remove(code);
|
||||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Readding " + admin.getName() + " to the admin list", true);
|
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Readding " + admin.getName() + " to the admin list", true);
|
||||||
if (playerSender != null)
|
|
||||||
{
|
admin.setName(playerSender.getName());
|
||||||
admin.setName(playerSender.getName());
|
admin.addIp(Ips.getIp(playerSender));
|
||||||
admin.addIp(Ips.getIp(playerSender));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.mbl.isMasterBuilder(playerSender))
|
if (!plugin.mbl.isMasterBuilder(playerSender))
|
||||||
{
|
{
|
||||||
@ -109,11 +135,8 @@ public class Command_verify extends FreedomCommand
|
|||||||
|
|
||||||
if (masterBuilder != null)
|
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());
|
masterBuilder.setLastLogin(new Date());
|
||||||
|
|
||||||
@ -127,10 +150,6 @@ public class Command_verify extends FreedomCommand
|
|||||||
plugin.al.save();
|
plugin.al.save();
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
plugin.rm.updateDisplay(playerSender);
|
plugin.rm.updateDisplay(playerSender);
|
||||||
if (playerSender != null)
|
|
||||||
{
|
|
||||||
plugin.rm.updateDisplay(playerSender);
|
|
||||||
}
|
|
||||||
playerSender.setOp(true);
|
playerSender.setOp(true);
|
||||||
msg(YOU_ARE_OP);
|
msg(YOU_ARE_OP);
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||||
@ -139,15 +158,14 @@ public class Command_verify extends FreedomCommand
|
|||||||
fPlayer.getFreezeData().setFrozen(false);
|
fPlayer.getFreezeData().setFrozen(false);
|
||||||
msg("You have been unfrozen.");
|
msg("You have been unfrozen.");
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (plugin.pv.isPlayerImpostor(playerSender))
|
||||||
{
|
{
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
|
||||||
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
FUtil.bcastMsg(playerSender.getName() + " has verified!", ChatColor.GOLD);
|
||||||
if (playerSender != null)
|
plugin.rm.updateDisplay(playerSender);
|
||||||
{
|
|
||||||
plugin.rm.updateDisplay(playerSender);
|
|
||||||
}
|
|
||||||
playerSender.setOp(true);
|
playerSender.setOp(true);
|
||||||
msg(YOU_ARE_OP);
|
msg(YOU_ARE_OP);
|
||||||
if (fPlayer.getFreezeData().isFrozen())
|
if (fPlayer.getFreezeData().isFrozen())
|
||||||
@ -156,9 +174,9 @@ public class Command_verify extends FreedomCommand
|
|||||||
msg("You have been unfrozen.");
|
msg("You have been unfrozen.");
|
||||||
}
|
}
|
||||||
plugin.pv.verifyPlayer(playerSender);
|
plugin.pv.verifyPlayer(playerSender);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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 = "/<command> <partialname>")
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user