[UNTESTED] implement player verification system

This commit is contained in:
Lemon
2018-03-24 20:41:45 +05:00
committed by Lemon
parent 50cb6c4ca9
commit 3576a9bb6e
12 changed files with 568 additions and 90 deletions

View File

@ -1,14 +1,17 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
import java.util.Random;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Link your discord account to your minecraft account", usage = "/<command>")
public class Command_linkdiscord extends FreedomCommand
{
@ -21,28 +24,45 @@ public class Command_linkdiscord extends FreedomCommand
msg("The discord verification system is currently disabled.", ChatColor.RED);
return true;
}
Admin admin = plugin.al.getAdmin(playerSender);
if (admin.getDiscordID() != null)
{
msg("Your minecraft account is already linked to a discord account.", ChatColor.RED);
return true;
}
if (plugin.dc.LINK_CODES.containsValue(admin))
{
msg("Your linking code is " + ChatColor.GREEN + plugin.dc.getCodeForAdmin(admin), ChatColor.AQUA);
if (plugin.al.isAdmin(playerSender)) {
Admin admin = plugin.al.getAdmin(playerSender);
if (admin.getDiscordID() != null) {
msg("Your minecraft account is already linked to a discord account.", ChatColor.RED);
return true;
}
if (Discord.LINK_CODES.containsValue(admin)) {
msg("Your linking code is " + ChatColor.GREEN + Discord.getCodeForAdmin(admin), ChatColor.AQUA);
} else {
String code = "";
Random random = new Random();
for (int i = 0; i < 5; i++) {
code += random.nextInt(10);
}
Discord.LINK_CODES.put(code, admin);
msg("Your linking code is " + ChatColor.GREEN + code, ChatColor.AQUA);
}
}
else
{
String code = "";
Random random = new Random();
for (int i = 0; i < 5; i++)
{
code += random.nextInt(10);
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
if (data.getDiscordID() != null) {
msg("Your minecraft account is already linked to a discord account.", ChatColor.RED);
return true;
}
if (Discord.PLAYER_LINK_CODES.containsValue(data)) {
msg("Your linking code is " + ChatColor.GREEN + Discord.getCodeForPlayer(data), ChatColor.AQUA);
} else {
String code = "";
Random random = new Random();
for (int i = 0; i < 5; i++) {
code += random.nextInt(10);
}
Discord.PLAYER_LINK_CODES.put(code, data);
msg("Your linking code is " + ChatColor.GREEN + code, ChatColor.AQUA);
}
plugin.dc.LINK_CODES.put(code, admin);
msg("Your linking code is " + ChatColor.GREEN + code, ChatColor.AQUA);
}
return true;
}