Merge pull request #8 from SupItsDillon/development

FS-5 Allow the verification system to be enabled / disabled in config (2)
This commit is contained in:
SupItsDillon 2020-12-14 19:09:57 +00:00 committed by GitHub
commit f8ce64d6c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 115 deletions

View File

@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,13 +15,17 @@ public class Command_manuallyverify extends FreedomCommand
@Override @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)
{ {
boolean enableBot = (ConfigEntry.DISCORD_VERIFICATION.getBoolean());
if (!plugin.dc.enabled) if (!plugin.dc.enabled)
{ {
msg("The Discord verification system is currently disabled", ChatColor.RED); msg("The Discord verification system is currently disabled", ChatColor.RED);
return true; return true;
} }
if (!enableBot)
{
msg("The Discord verification system is currently disabled", ChatColor.RED);
return true;
}
if (args.length == 0) if (args.length == 0)
{ {
return false; return false;

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -20,10 +21,12 @@ public class Command_playerverification extends FreedomCommand
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)
{ {
PlayerData target = plugin.pl.getData(playerSender); PlayerData target = plugin.pl.getData(playerSender);
boolean enableBot = (ConfigEntry.DISCORD_VERIFICATION.getBoolean());
List<String> ips = new ArrayList<>(); List<String> ips = new ArrayList<>();
ips.addAll(target.getIps()); ips.addAll(target.getIps());
if(enableBot)
{
if (args.length == 1) if (args.length == 1)
{ {
if (args[0].equalsIgnoreCase("clearips")) if (args[0].equalsIgnoreCase("clearips"))
@ -142,6 +145,12 @@ public class Command_playerverification extends FreedomCommand
return false; return false;
} }
} }
else
{
msg("The Discord verification system is currently disabled", ChatColor.RED);
}
return true;
}
@Override @Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
@ -17,12 +18,17 @@ public class Command_verify extends FreedomCommand
@Override @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)
{ {
boolean enableBot = (ConfigEntry.DISCORD_VERIFICATION.getBoolean());
if (!plugin.dc.enabled) if (!plugin.dc.enabled)
{ {
msg("The Discord verification system is currently disabled", ChatColor.RED); msg("The Discord verification system is currently disabled", ChatColor.RED);
return true; return true;
} }
if (!enableBot)
{
msg("The Discord verification system is currently disabled", ChatColor.RED);
return true;
}
if (senderIsConsole) if (senderIsConsole)
{ {
msg("/manuallyverify <playername>", ChatColor.WHITE); msg("/manuallyverify <playername>", ChatColor.WHITE);

View File

@ -69,6 +69,7 @@ public enum ConfigEntry
SERVER_WHITELIST_MOTD(String.class, "server.motds.whitelist"), SERVER_WHITELIST_MOTD(String.class, "server.motds.whitelist"),
SERVER_FULL_MOTD(String.class, "server.motds.full"), SERVER_FULL_MOTD(String.class, "server.motds.full"),
// //
DISCORD_VERIFICATION(Boolean.class, "discord.verification"),
DISCORD_TOKEN(String.class, "discord.token"), DISCORD_TOKEN(String.class, "discord.token"),
DISCORD_REPORT_CHANNEL_ID(String.class, "discord.report_channel_id"), DISCORD_REPORT_CHANNEL_ID(String.class, "discord.report_channel_id"),
DISCORD_CHAT_CHANNEL_ID(String.class, "discord.chat_channel_id"), DISCORD_CHAT_CHANNEL_ID(String.class, "discord.chat_channel_id"),

View File

@ -59,9 +59,16 @@ public class Discord extends FreedomService
public static JDA bot = null; public static JDA bot = null;
public Boolean enabled = false; public Boolean enabled = false;
public Boolean enableBot = false;
public void startBot() public void startBot()
{ {
enableBot = (ConfigEntry.DISCORD_VERIFICATION.getBoolean());
if (!enableBot)
{
FLog.info("Discord Verification has been manually disabled.");
return;
}
enabled = !Strings.isNullOrEmpty(ConfigEntry.DISCORD_TOKEN.getString()); enabled = !Strings.isNullOrEmpty(ConfigEntry.DISCORD_TOKEN.getString());
if (!enabled) if (!enabled)
{ {

View File

@ -53,6 +53,8 @@ server:
# Discord # Discord
discord: discord:
# Do you want to enable the bot? (Disabled by default)
verification: false
# If you do not have a token, make a bot account and get one at https://discordapp.com/developers/applications/me # If you do not have a token, make a bot account and get one at https://discordapp.com/developers/applications/me
token: '' token: ''
# The official discord server's ID for this server # The official discord server's ID for this server