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,10 +22,12 @@ 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 (enableBot == true)
{
if (args.length == 1) if (args.length == 1)
{ {
if (args[0].equalsIgnoreCase("clearips")) if (args[0].equalsIgnoreCase("clearips"))
@ -64,11 +68,10 @@ public class Command_playerverification extends FreedomCommand
} }
PlayerData data = plugin.pl.getData(playerSender); PlayerData data = plugin.pl.getData(playerSender);
switch (args[0].toLowerCase()) switch (args[0].toLowerCase())
{ {
case "enable": case "enable":
{
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);
@ -88,10 +91,8 @@ public class Command_playerverification extends FreedomCommand
plugin.pl.save(data); plugin.pl.save(data);
msg("Re-enabled Discord verification.", ChatColor.GREEN); msg("Re-enabled Discord verification.", ChatColor.GREEN);
return true; return true;
}
case "disable": case "disable":
{
if (!data.hasVerification()) if (!data.hasVerification())
{ {
msg("Discord verification is already disabled for you.", ChatColor.RED); msg("Discord verification is already disabled for you.", ChatColor.RED);
@ -101,20 +102,16 @@ public class Command_playerverification extends FreedomCommand
plugin.pl.save(data); plugin.pl.save(data);
msg("Disabled Discord verification.", ChatColor.GREEN); msg("Disabled Discord verification.", ChatColor.GREEN);
return true; return true;
}
case "status": case "status":
{
boolean enabled = target.hasVerification(); boolean enabled = target.hasVerification();
boolean specified = target.getDiscordID() != null; boolean specified = target.getDiscordID() != null;
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false")); 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 + "Discord ID: " + (specified ? ChatColor.GREEN + target.getDiscordID() : ChatColor.RED + "not set"));
msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10"); msg(ChatColor.GRAY + "Backup Codes: " + data.getBackupCodes().size() + "/" + "10");
return true; return true;
}
case "genbackupcodes": case "genbackupcodes":
{
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);
@ -137,12 +134,17 @@ public class Command_playerverification extends FreedomCommand
msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED); msg("Failed to generate backup codes, please contact a developer (preferably Seth)", ChatColor.RED);
} }
return true; return true;
}
default: default:
return false; 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)
{ {