Tested to be working, but made some minor changes.

This commit is contained in:
ZeroEpoch1969
2018-03-24 18:41:51 -07:00
parent 01223d44ef
commit 88f89d7e67
8 changed files with 201 additions and 100 deletions

View File

@ -9,33 +9,41 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | status> <discord | forum>", aliases = "playerverification, opverification, opverify, opv")
public class Command_playerverify extends FreedomCommand {
@CommandParameters(description = "Manage your verification", usage = "/<command> <enable | disable | clearips | status> <discord | forum>", aliases = "playerverification,pv")
public class Command_playerverify extends FreedomCommand
{
@Override
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length < 2) {
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 2)
{
return false;
}
if (plugin.al.isAdmin(sender)) {
if (plugin.al.isAdmin(sender))
{
msg("This command is only for OP's.", ChatColor.RED);
return true;
}
switch (args[0].toLowerCase()) {
switch (args[0].toLowerCase())
{
case "enable":
switch (args[1].toLowerCase()) {
switch (args[1].toLowerCase())
{
case "discord":
if (!plugin.dc.enabled) {
if (!plugin.dc.enabled)
{
msg("The discord verification system is currently disabled.", ChatColor.RED);
return true;
}
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
if (data.isDiscordVerificationEnabled()) {
if (data.isDiscordVerificationEnabled())
{
msg("Discord verification is already enabled for you.", ChatColor.RED);
return true;
}
data.setDiscordVerificationEnabled(true);
plugin.pv.saveVerificationData(data);
msg("Enabled discord verification. Please type /linkdiscord to link a discord account.", ChatColor.AQUA);
msg("Enabled discord verification. Please type /linkdiscord to link a discord account.", ChatColor.GREEN);
return true;
case "forum":
msg("TODO. This will be enabled in a later update. Please use discord verification instead.");
@ -44,16 +52,18 @@ public class Command_playerverify extends FreedomCommand {
return false;
}
case "disable":
switch (args[1].toLowerCase()) {
switch (args[1].toLowerCase())
{
case "discord":
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
if (!data.isDiscordVerificationEnabled()) {
if (!data.isDiscordVerificationEnabled())
{
msg("Discord verification is already disabled for you.", ChatColor.RED);
return true;
}
data.setDiscordVerificationEnabled(false);
plugin.pv.saveVerificationData(data);
msg("Disabled discord verification.", ChatColor.AQUA);
msg("Disabled discord verification.", ChatColor.GREEN);
return true;
case "forum":
msg("TODO. Forum verification will be enabled in a later update.");
@ -62,13 +72,14 @@ public class Command_playerverify extends FreedomCommand {
return false;
}
case "status":
switch (args[1].toLowerCase()) {
switch (args[1].toLowerCase())
{
case "discord":
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
boolean enabled = data.isDiscordVerificationEnabled();
boolean specified = data.getDiscordID() != null;
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.AQUA + "true" : ChatColor.RED + "false"));
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.AQUA + data.getDiscordID() : ChatColor.RED + "not set"));
msg(ChatColor.GRAY + "Discord Verification Enabled: " + (enabled ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
msg(ChatColor.GRAY + "Discord ID: " + (specified ? ChatColor.GREEN + data.getDiscordID() : ChatColor.RED + "not set"));
return true;
case "forum":
msg("TODO. Forum verification will be enabled in a later update.");
@ -79,8 +90,10 @@ public class Command_playerverify extends FreedomCommand {
case "clearips":
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
int cleared = 0;
for (String ip : data.getIPs()) {
if (!ip.equals(Ips.getIp(playerSender))) {
for (String ip : data.getIPs())
{
if (!ip.equals(Ips.getIp(playerSender)))
{
data.removeIp(ip);
cleared++;
}

View File

@ -11,39 +11,48 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Date;
import java.util.Random;
@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 = "/<command> [code]")
public class Command_verify extends FreedomCommand {
public class Command_verify extends FreedomCommand
{
@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);
return true;
}
if (!plugin.al.isAdminImpostor(playerSender) && !plugin.pv.isPlayerImpostor(playerSender)) {
if (!plugin.al.isAdminImpostor(playerSender) && !plugin.pv.isPlayerImpostor(playerSender))
{
msg("You are not an imposter, therefore you do not need to verify.", ChatColor.RED);
return true;
}
String discordId = "";
if (plugin.al.isAdminImpostor(playerSender)) {
if (plugin.al.isAdminImpostor(playerSender))
{
Admin admin = plugin.al.getEntryByName(playerSender.getName());
if (admin.getDiscordID() == null) {
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();
} else {
if (plugin.pv.isPlayerImpostor(playerSender)) {
if (plugin.pv.getVerificationPlayer(playerSender).getDiscordID() == null) {
}
else
{
if (plugin.pv.isPlayerImpostor(playerSender))
{
if (plugin.pv.getVerificationPlayer(playerSender).getDiscordID() == null)
{
msg("You do not have a discord account linked to your minecraft account, please verify the manual way.", ChatColor.RED);
return true;
}
@ -51,27 +60,36 @@ public class Command_verify extends FreedomCommand {
}
}
if (args.length < 1) {
if (args.length < 1)
{
String code = "";
Random random = new Random();
for (int i = 0; i < 10; i++) {
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 <code>", ChatColor.GREEN);
} else {
}
else
{
String code = args[0];
if (!Discord.VERIFY_CODES.contains(code)) {
if (!Discord.VERIFY_CODES.contains(code))
{
msg("You have entered an invalid verification code", ChatColor.RED);
return true;
} else {
if (plugin.al.isAdminImpostor(playerSender)) {
}
else
{
if (plugin.al.isAdminImpostor(playerSender))
{
Admin admin = plugin.al.getEntryByName(playerSender.getName());
Discord.VERIFY_CODES.remove(code);
FUtil.bcastMsg(playerSender.getName() + " has verified themself!", ChatColor.GOLD);
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Readding " + admin.getName() + " to the admin list", true);
if (playerSender != null) {
if (playerSender != null)
{
admin.setName(playerSender.getName());
admin.addIp(Ips.getIp(playerSender));
}
@ -80,14 +98,27 @@ public class Command_verify extends FreedomCommand {
plugin.al.save();
plugin.al.updateTables();
plugin.rm.updateDisplay(playerSender);
if (playerSender != null)
{
plugin.rm.updateDisplay(playerSender);
}
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
if (fPlayer.getFreezeData().isFrozen()) {
if (fPlayer.getFreezeData().isFrozen())
{
fPlayer.getFreezeData().setFrozen(false);
msg("You have been unfrozen.");
}
} else {
}
else
{
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
if (fPlayer.getFreezeData().isFrozen()) {
FUtil.bcastMsg(playerSender.getName() + " has verified themself!", ChatColor.GOLD);
if (playerSender != null)
{
plugin.rm.updateDisplay(playerSender);
}
if (fPlayer.getFreezeData().isFrozen())
{
fPlayer.getFreezeData().setFrozen(false);
msg("You have been unfrozen.");
}

View File

@ -27,6 +27,7 @@ public class Command_verifyplayer extends FreedomCommand {
}
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), true);
plugin.pv.verifyPlayer(player);
plugin.rm.updateDisplay(player);
return true;
}