Resolves TFPatches/TotalFreedomMod#57 (#66)

After a bit of recreating the PlayerVerification system, it will work now.
This commit is contained in:
Nathan Curran
2018-06-02 00:13:40 +10:00
committed by Lemon
parent 45bda95a75
commit ee7dbd56da
6 changed files with 140 additions and 191 deletions

View File

@ -25,19 +25,25 @@ public class Command_linkdiscord extends FreedomCommand
return true;
}
if (plugin.al.isAdmin(playerSender)) {
if (plugin.al.isAdmin(playerSender))
{
Admin admin = plugin.al.getAdmin(playerSender);
if (admin.getDiscordID() != null) {
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)) {
if (Discord.LINK_CODES.containsValue(admin))
{
msg("Your linking code is " + ChatColor.GREEN + Discord.getCodeForAdmin(admin), ChatColor.AQUA);
} else {
}
else
{
String code = "";
Random random = new Random();
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++)
{
code += random.nextInt(10);
}
Discord.LINK_CODES.put(code, admin);
@ -47,17 +53,22 @@ public class Command_linkdiscord extends FreedomCommand
else
{
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
if (data.getDiscordID() != null) {
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)) {
if (Discord.PLAYER_LINK_CODES.containsValue(data))
{
msg("Your linking code is " + ChatColor.GREEN + Discord.getCodeForPlayer(data), ChatColor.AQUA);
} else {
}
else
{
String code = "";
Random random = new Random();
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++)
{
code += random.nextInt(10);
}
Discord.PLAYER_LINK_CODES.put(code, data);

View File

@ -22,7 +22,7 @@ public class Command_playerverify extends FreedomCommand
{
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
int cleared = 0;
for (String ip : data.getIPs())
for (String ip : data.getIps())
{
if (!ip.equals(Ips.getIp(playerSender)))
{
@ -30,6 +30,7 @@ public class Command_playerverify extends FreedomCommand
cleared++;
}
}
msg("Cleared all IP's except your current IP \"" + Ips.getIp(playerSender) + "\"");
msg("Cleared " + cleared + " IP's.");
plugin.pv.saveVerificationData(data);
@ -59,12 +60,12 @@ public class Command_playerverify extends FreedomCommand
return true;
}
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
if (data.isDiscordVerificationEnabled())
if (data.getDiscordEnabled())
{
msg("Discord verification is already enabled for you.", ChatColor.RED);
return true;
}
data.setDiscordVerificationEnabled(true);
data.setDiscordEnabled(true);
plugin.pv.saveVerificationData(data);
msg("Enabled discord verification. Please type /linkdiscord to link a discord account.", ChatColor.GREEN);
return true;
@ -79,12 +80,12 @@ public class Command_playerverify extends FreedomCommand
{
case "discord":
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
if (!data.isDiscordVerificationEnabled())
if (!data.getDiscordEnabled())
{
msg("Discord verification is already disabled for you.", ChatColor.RED);
return true;
}
data.setDiscordVerificationEnabled(false);
data.setDiscordEnabled(false);
plugin.pv.saveVerificationData(data);
msg("Disabled discord verification.", ChatColor.GREEN);
return true;
@ -99,10 +100,10 @@ public class Command_playerverify extends FreedomCommand
{
case "discord":
VPlayer data = plugin.pv.getVerificationPlayer(playerSender);
boolean enabled = data.isDiscordVerificationEnabled();
boolean specified = data.getDiscordID() != null;
boolean enabled = data.getDiscordEnabled();
boolean specified = data.getDiscordId() != null;
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"));
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.");

View File

@ -12,6 +12,7 @@ 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;
@ -52,12 +53,12 @@ public class Command_verify extends FreedomCommand
{
if (plugin.pv.isPlayerImpostor(playerSender))
{
if (plugin.pv.getVerificationPlayer(playerSender).getDiscordID() == null)
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;
}
discordId = plugin.pv.getVerificationPlayer(playerSender).getDiscordID();
discordId = plugin.pv.getVerificationPlayer(playerSender).getDiscordId();
}
}
@ -109,7 +110,7 @@ public class Command_verify extends FreedomCommand
if (masterBuilder != null)
{
if (playerSender!= null)
if (playerSender != null)
{
masterBuilder.setName(playerSender.getName());
masterBuilder.addIp(Ips.getIp(playerSender));