Update Command_playerverification.java

discord enable disable verification
This commit is contained in:
SupItsDillon 2020-12-08 19:15:55 +00:00 committed by GitHub
parent 950c975e8f
commit fb3cdf3603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -20,129 +22,129 @@ public class Command_playerverification extends FreedomCommand
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)
{ {
PlayerData target = plugin.pl.getData(playerSender); PlayerData target = plugin.pl.getData(playerSender);
boolean enableBot = (ConfigEntry.DISCORD_VERIFICATION.getBoolean());
List<String> ips = new ArrayList<>(); List<String> ips = new ArrayList<>();
ips.addAll(target.getIps()); ips.addAll(target.getIps());
if (args.length == 1) if (enableBot == true)
{ {
if (args[0].equalsIgnoreCase("clearips")) if (args.length == 1)
{ {
int cleared = 0; if (args[0].equalsIgnoreCase("clearips"))
for (String ip : ips)
{ {
if (!ip.equals(FUtil.getIp(playerSender))) int cleared = 0;
for (String ip : ips)
{ {
target.removeIp(ip); if (!ip.equals(FUtil.getIp(playerSender)))
cleared++; {
target.removeIp(ip);
cleared++;
}
} }
}
msg("Cleared all IP's except your current IP \"" + FUtil.getIp(playerSender) + "\""); msg("Cleared all IP's except your current IP \"" + FUtil.getIp(playerSender) + "\"");
msg("Cleared " + cleared + " IP's."); msg("Cleared " + cleared + " IP's.");
plugin.pl.save(target); plugin.pl.save(target);
plugin.pl.syncIps(target); plugin.pl.syncIps(target);
return true; return true;
}
else if (args[0].equalsIgnoreCase("clearip"))
{
if (args.length < 2)
{
return false;
}
target.removeIp(args[1]);
msg("Removed" + args[1] + " from your list of IPs");
plugin.pl.save(target);
plugin.pl.syncIps(target);
return true;
}
} }
else if (args[0].equalsIgnoreCase("clearip"))
if (args.length < 1)
{ {
if (args.length < 2)
{
return false;
}
target.removeIp(args[1]);
msg("Removed" + args[1] + " from your list of IPs");
plugin.pl.save(target);
plugin.pl.syncIps(target);
return true;
}
}
if (args.length < 1)
{
return false;
}
PlayerData data = plugin.pl.getData(playerSender);
switch (args[0].toLowerCase())
{
case "enable":
{
if (!plugin.dc.enabled)
{
msg("The Discord verification system is currently disabled.", ChatColor.RED);
return true;
}
else if (data.hasVerification())
{
msg("Discord verification is already enabled for you.", ChatColor.RED);
return true;
}
else if (data.getDiscordID() == null)
{
msg("Please link a discord account with /linkdiscord.", ChatColor.RED);
return true;
}
data.setVerification(true);
plugin.pl.save(data);
msg("Re-enabled Discord verification.", ChatColor.GREEN);
return true;
}
case "disable":
{
if (!data.hasVerification())
{
msg("Discord verification is already disabled for you.", ChatColor.RED);
return true;
}
data.setVerification(false);
plugin.pl.save(data);
msg("Disabled Discord verification.", ChatColor.GREEN);
return true;
}
case "status":
{
boolean enabled = target.hasVerification();
boolean specified = target.getDiscordID() != null;
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordID() : ChatColor.RED + "not set"));
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
return true;
}
case "genbackupcodes":
{
if (!plugin.dc.enabled)
{
msg("The Discord verification system is currently disabled.", ChatColor.RED);
return true;
}
else if (!data.hasVerification())
{
msg("Discord verification is not enabled for you.", ChatColor.RED);
return true;
}
boolean generated = plugin.dc.sendBackupCodes(data);
if (generated)
{
msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
}
else
{
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
}
return true;
}
default:
return false; return false;
} }
}
PlayerData data = plugin.pl.getData(playerSender);
switch (args[0].toLowerCase())
{
case "enable":
if (!plugin.dc.enabled)
{
msg("The Discord verification system is currently disabled.", ChatColor.RED);
return true;
}
else if (data.hasVerification())
{
msg("Discord verification is already enabled for you.", ChatColor.RED);
return true;
}
else if (data.getDiscordID() == null)
{
msg("Please link a discord account with /linkdiscord.", ChatColor.RED);
return true;
}
data.setVerification(true);
plugin.pl.save(data);
msg("Re-enabled Discord verification.", ChatColor.GREEN);
return true;
case "disable":
if (!data.hasVerification())
{
msg("Discord verification is already disabled for you.", ChatColor.RED);
return true;
}
data.setVerification(false);
plugin.pl.save(data);
msg("Disabled Discord verification.", ChatColor.GREEN);
return true;
case "status":
boolean enabled = target.hasVerification();
boolean specified = target.getDiscordID() != null;
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordID() : ChatColor.RED + "not set"));
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
return true;
case "genbackupcodes":
if (!plugin.dc.enabled)
{
msg("The Discord verification system is currently disabled.", ChatColor.RED);
return true;
}
else if (!data.hasVerification())
{
msg("Discord verification is not enabled for you.", ChatColor.RED);
return true;
}
boolean generated = plugin.dc.sendBackupCodes(data);
if (generated)
{
msg("Your backup codes have been sent to your discord account. They can be re-generated at anytime.", ChatColor.GREEN);
}
else
{
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
}
return true;
default:
return false;
}
}
else
{
msg("The Discord verification system is currently disabled", ChatColor.RED);
}
return true;
}
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{ {