2018-03-24 15:41:45 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
|
|
|
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
import net.pravian.aero.util.Ips;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
2018-03-25 01:41:51 +00:00
|
|
|
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | status> <discord | forum>", aliases = "playerverification,pv")
|
|
|
|
public class Command_playerverify extends FreedomCommand
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
@Override
|
2018-03-25 01:41:51 +00:00
|
|
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2018-03-26 00:12:47 +00:00
|
|
|
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
if (args[0].equalsIgnoreCase("clearips"))
|
|
|
|
{
|
|
|
|
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
|
|
|
int cleared = 0;
|
2018-06-01 14:13:40 +00:00
|
|
|
for (String ip : data.getIps())
|
2018-03-26 00:12:47 +00:00
|
|
|
{
|
|
|
|
if (!ip.equals(Ips.getIp(playerSender)))
|
|
|
|
{
|
|
|
|
data.removeIp(ip);
|
|
|
|
cleared++;
|
|
|
|
}
|
|
|
|
}
|
2018-06-01 14:13:40 +00:00
|
|
|
|
2018-03-26 00:12:47 +00:00
|
|
|
msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
|
|
|
|
msg("Cleared " + cleared + " IP's.");
|
|
|
|
plugin.pv.saveVerificationData(data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-25 01:41:51 +00:00
|
|
|
if (args.length < 2)
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-03-26 00:12:47 +00:00
|
|
|
|
2018-03-25 01:41:51 +00:00
|
|
|
if (plugin.al.isAdmin(sender))
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
msg("This command is only for OP's.", ChatColor.RED);
|
|
|
|
return true;
|
|
|
|
}
|
2018-03-25 01:41:51 +00:00
|
|
|
switch (args[0].toLowerCase())
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
case "enable":
|
2018-03-25 01:41:51 +00:00
|
|
|
switch (args[1].toLowerCase())
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
case "discord":
|
2018-03-25 01:41:51 +00:00
|
|
|
if (!plugin.dc.enabled)
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
msg("The discord verification system is currently disabled.", ChatColor.RED);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
2018-06-01 14:13:40 +00:00
|
|
|
if (data.getDiscordEnabled())
|
2018-03-25 01:41:51 +00:00
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
msg("Discord verification is already enabled for you.", ChatColor.RED);
|
|
|
|
return true;
|
|
|
|
}
|
2018-06-01 14:13:40 +00:00
|
|
|
data.setDiscordEnabled(true);
|
2018-03-24 15:41:45 +00:00
|
|
|
plugin.pv.saveVerificationData(data);
|
2018-03-25 01:41:51 +00:00
|
|
|
msg("Enabled discord verification. Please type /linkdiscord to link a discord account.", ChatColor.GREEN);
|
2018-03-24 15:41:45 +00:00
|
|
|
return true;
|
|
|
|
case "forum":
|
|
|
|
msg("TODO. This will be enabled in a later update. Please use discord verification instead.");
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case "disable":
|
2018-03-25 01:41:51 +00:00
|
|
|
switch (args[1].toLowerCase())
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
case "discord":
|
|
|
|
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
2018-06-01 14:13:40 +00:00
|
|
|
if (!data.getDiscordEnabled())
|
2018-03-25 01:41:51 +00:00
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
msg("Discord verification is already disabled for you.", ChatColor.RED);
|
|
|
|
return true;
|
|
|
|
}
|
2018-06-01 14:13:40 +00:00
|
|
|
data.setDiscordEnabled(false);
|
2018-03-24 15:41:45 +00:00
|
|
|
plugin.pv.saveVerificationData(data);
|
2018-03-25 01:41:51 +00:00
|
|
|
msg("Disabled discord verification.", ChatColor.GREEN);
|
2018-03-24 15:41:45 +00:00
|
|
|
return true;
|
|
|
|
case "forum":
|
|
|
|
msg("TODO. Forum verification will be enabled in a later update.");
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case "status":
|
2018-03-25 01:41:51 +00:00
|
|
|
switch (args[1].toLowerCase())
|
|
|
|
{
|
2018-03-24 15:41:45 +00:00
|
|
|
case "discord":
|
|
|
|
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
|
2018-06-01 14:13:40 +00:00
|
|
|
boolean enabled = data.getDiscordEnabled();
|
|
|
|
boolean specified = data.getDiscordId() != null;
|
2018-03-25 01:41:51 +00:00
|
|
|
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
2018-06-01 14:13:40 +00:00
|
|
|
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + data.getDiscordId() : ChatColor.RED + "not set"));
|
2018-03-24 15:41:45 +00:00
|
|
|
return true;
|
|
|
|
case "forum":
|
|
|
|
msg("TODO. Forum verification will be enabled in a later update.");
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|