I think I have a better solution to #109

This commit is contained in:
ZeroEpoch1969
2018-07-30 22:58:50 -07:00
parent b702c1cec5
commit 12f023196a
11 changed files with 132 additions and 123 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
import java.io.File;
import java.io.IOException;
import java.util.Map;
public class PlayerVerification extends FreedomService
@ -47,7 +48,7 @@ public class PlayerVerification extends FreedomService
{
VPlayer vPlayer = getVerificationPlayer(player);
return !plugin.al.isAdmin(player)
&& (vPlayer.getForumEnabled() || vPlayer.getDiscordEnabled())
&& (vPlayer.getEnabled())
&& !vPlayer.getIps().contains(Ips.getIp(player));
}
@ -176,6 +177,23 @@ public class PlayerVerification extends FreedomService
{
final YamlConfig config = new YamlConfig(plugin, getConfigFile(player.getName().toLowerCase()), false);
config.load();
// Convert discordEnabled to enabled, and remove forumEnabled.
if (config.get("discordEnabled") != null)
{
config.set("enabled", config.getBoolean("discordEnabled"));
config.set("discordEnabled", null);
config.set("forumEnabled", null);
try
{
config.save(getConfigFile(player.getName().toLowerCase()));
}
catch (IOException e)
{
FLog.warning("Failed to convert Player Verification entry for " + player.getName());
}
}
return config;
}
}

View File

@ -28,10 +28,7 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
private String forumUsername = null;
@Getter
@Setter
private Boolean discordEnabled = false;
@Getter
@Setter
private Boolean forumEnabled = false;
private Boolean enabled = false;
@Getter
@Setter
private String tag = null;
@ -53,9 +50,7 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
ips.clear();
ips.addAll(cs.getStringList("ips"));
discordId = cs.getString("discordId", null);
forumUsername = cs.getString("forumUsername", null);
discordEnabled = cs.getBoolean("discordEnabled", false);
forumEnabled = cs.getBoolean("forumEnabled", false);
enabled = cs.getBoolean("enabled", false);
tag = cs.getString("tag", null);
}
@ -65,9 +60,7 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
Validate.isTrue(isValid(), "Could not save player verification entry: " + name + ". Entry not valid!");
cs.set("name", name);
cs.set("discordId", discordId);
cs.set("forumUsername", forumUsername);
cs.set("discordEnabled", discordEnabled);
cs.set("forumEnabled", forumEnabled);
cs.set("enabled", enabled);
cs.set("tag", tag);
cs.set("ips", Lists.newArrayList(ips));
}
@ -79,7 +72,7 @@ public class VPlayer implements ConfigLoadable, ConfigSavable, Validatable
public boolean addIp(String ip)
{
return ips.contains(ip) ? false : ips.add(ip);
return !ips.contains(ip) && ips.add(ip);
}
public boolean removeIp(String ip)