Split gcmd sub cmds out n other stuff

This commit is contained in:
Seth 2020-07-31 21:10:44 -07:00
parent 891e5c2f12
commit 76bb2d08ac
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
21 changed files with 431 additions and 255 deletions

11
pom.xml
View File

@ -240,9 +240,16 @@
<dependency>
<groupId>com.github.speedxx</groupId>
<artifactId>TFGuilds</artifactId>
<version>master-SNAPSHOT</version>
<version>master</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
@ -418,7 +425,7 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.17</version>
<version>3.1.1</version>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle.xml</configLocation>

View File

@ -2,7 +2,10 @@ package me.totalfreedom.totalfreedommod;
import com.sk89q.worldedit.bukkit.BukkitConfiguration;
import java.io.File;
import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.util.FileUtil;
@ -25,6 +28,15 @@ public class BackupManager extends FreedomService
createBackups(file, false);
}
public void createAllBackups()
{
createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
createBackups(PermbanList.CONFIG_FILENAME);
createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
createBackups(PunishmentList.CONFIG_FILENAME);
createBackups("database.db");
}
public void createBackups(String file, boolean onlyWeekly)
{
final String save = file.split("\\.")[0];

View File

@ -181,33 +181,20 @@ public class TotalFreedomMod extends JavaPlugin
FUtil.deleteFolder(new File("./_deleteme"));
fsh = new FreedomServiceHandler();
config = new MainConfig();
config.load();
cl = new CommandLoader();
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
for (Class<? extends FreedomCommand> commandClass : commandClasses)
{
try
{
cl.add(commandClass.newInstance());
}
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
{
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
}
}
cl.loadCommands();
BackupManager backups = new BackupManager();
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
backups.createBackups(PermbanList.CONFIG_FILENAME);
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
backups.createBackups(PunishmentList.CONFIG_FILENAME);
backups.createBackups("database.db");
backups.createAllBackups();
config = new MainConfig(this);
config.load();
if (FUtil.inDeveloperMode())
{
FLog.debug("Developer mode enabled.");
}
permissions = new PermissionConfig(this);
permissions.load();

View File

@ -166,7 +166,20 @@ public class Ban implements IConfig
{
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
message.append(!hasUsername() ? "r IP address is" : " are").append(" temporarily banned from this server.");
if (!hasUsername())
{
message.append("r IP address is");
}
else if (!hasIps())
{
message.append("r username is");
}
else
{
message.append(" are");
}
message.append(" temporarily banned from this server.");
message.append("\nAppeal at ").append(ChatColor.BLUE)
.append(ConfigEntry.SERVER_BAN_URL.getString());

View File

@ -3,14 +3,13 @@ package me.totalfreedom.totalfreedommod.bridge;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.TFGuilds;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class TFGuildsBridge extends FreedomService
{
private TFGuilds tfGuildsPlugin = null;
public boolean enabled = false;
@Override
public void onStart()
@ -22,31 +21,39 @@ public class TFGuildsBridge extends FreedomService
{
}
public TFGuilds getTfGuildsPlugin()
public boolean isTFGuildsEnabled()
{
if (tfGuildsPlugin == null)
if (enabled)
{
try
return true;
}
try
{
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
if (tfGuilds != null && tfGuilds.isEnabled())
{
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
if (tfGuilds != null)
if (tfGuilds instanceof TFGuilds)
{
if (tfGuilds instanceof TFGuilds)
{
tfGuildsPlugin = (TFGuilds)tfGuilds;
}
enabled = true;
return true;
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return tfGuildsPlugin;
catch (NoClassDefFoundError ex)
{
return false;
}
return false;
}
public boolean inGuildChat(Player player)
{
if (!isTFGuildsEnabled())
{
return false;
}
return Common.IN_GUILD_CHAT.contains(player);
}
}

View File

@ -3,8 +3,11 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.reflections.Reflections;
public class CommandLoader extends FreedomService
{
@ -52,6 +55,26 @@ public class CommandLoader extends FreedomService
return false;
}
public void loadCommands()
{
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
for (Class<? extends FreedomCommand> commandClass : commandClasses)
{
try
{
FLog.debug("Loading command class " + commandClass.getSimpleName());
add(commandClass.newInstance());
}
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
{
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
}
}
}
public int getCommandAmount()
{
return commands.size();

View File

@ -0,0 +1,82 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
public class Command_banip extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
boolean silent = false;
String reason = null;
String ip = args[0];
if (!FUtil.isValidIPv4(ip))
{
msg(ip + " is not a valid IP address", ChatColor.RED);
return true;
}
if (plugin.bm.getByIp(ip) != null)
{
msg("The IP " + ip + " is already banned", ChatColor.RED);
return true;
}
if (args[args.length - 1].equalsIgnoreCase("-q"))
{
silent = true;
if (args.length >= 2)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
// Ban player
Ban ban = Ban.forPlayerIp(ip, sender, null, reason);
plugin.bm.addBan(ban);
// Kick player and handle others on IP
for (Player player : server.getOnlinePlayers())
{
if (FUtil.getIp(player).equals(ip))
{
player.kickPlayer(ban.bakeKickMessage());
}
if (!silent)
{
// Broadcast
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
player.sendMessage(message);
}
}
return true;
}
}

View File

@ -0,0 +1,68 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
public class Command_banname extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
boolean silent = false;
String reason = null;
String name = args[0];;
if (plugin.bm.getByUsername(name) != null)
{
msg("The name " + name + " is already banned", ChatColor.RED);
return true;
}
if (args[args.length - 1].equalsIgnoreCase("-q"))
{
silent = true;
if (args.length >= 2)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
// Ban player
Ban ban = Ban.forPlayerName(name, sender, null, reason);
plugin.bm.addBan(ban);
if (!silent)
{
FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
}
Player player = getPlayer(name);
if (player != null)
{
player.kickPlayer(ban.bakeKickMessage());
}
return true;
}
}

View File

@ -63,9 +63,16 @@ public class Command_doom extends FreedomCommand
// Deop
player.setOp(false);
String reason = null;
if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
// Ban player
Ban ban = Ban.forPlayer(player, sender);
ban.setReason("&cFUCKOFF");
ban.setReason((reason == null ? "FUCKOFF" : reason));
for (String playerIp : plugin.pl.getData(player).getIps())
{
ban.addIp(playerIp);
@ -88,13 +95,6 @@ public class Command_doom extends FreedomCommand
// Shoot the player in the sky
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
String reason = null;
if (args.length > 1)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
final String kickReason = (reason == null ? "FUCKOFF, and get your shit together!" : reason);
// Log doom

View File

@ -1,188 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans or unbans any player, including those offline.", usage = "/<command> <ban <username> [reason] | unban <username> | banip <ip> <reason> | unbanip <ip> | nameban <name> | unbanname <name>>")
public class Command_glist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 2)
{
return false;
}
String username = null;
final List<String> ips = new ArrayList<>();
boolean usingIp = false;
String banIp = null;
if (args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$") || args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([*])\\.([*])$"))
{
usingIp = true;
banIp = args[1];
}
final Player player = getPlayer(args[1]);
if (!usingIp)
{
if (player == null)
{
final PlayerData entry = plugin.pl.getData(args[1]);
if (entry == null)
{
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
return true;
}
username = entry.getName();
ips.addAll(entry.getIps());
}
else
{
final PlayerData entry = plugin.pl.getData(player);
username = entry.getName();
ips.addAll(entry.getIps());
}
}
switch (args[0])
{
case "ban":
case "gtfo":
if (usingIp)
{
msg("Please specify a player, not an ip.");
return true;
}
final String playerBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban playerBan = Ban.forPlayerName(username, sender, null, playerBanReason);
for (String ip : ips)
{
playerBan.addIp(ip);
playerBan.addIp(FUtil.getFuzzyIp(ip));
}
FUtil.adminAction(sender.getName(), "Banning " + username, true);
playerMsg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
plugin.bm.addBan(playerBan);
if (player != null)
{
player.kickPlayer(playerBan.bakeKickMessage());
}
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, null));
return true;
case "unban":
case "pardon":
if (usingIp)
{
msg("Please specify a player, not an ip.");
return true;
}
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
playerMsg(sender, ChatColor.GRAY + username + " has been unbanned and IP is: " + StringUtils.join(ips, ", "));
plugin.bm.removeBan(plugin.bm.getByUsername(username));
for (String ip : ips)
{
Ban playerUnban = plugin.bm.getByIp(ip);
if (playerUnban != null)
{
plugin.bm.removeBan(playerUnban);
}
playerUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
if (playerUnban != null)
{
plugin.bm.removeBan(playerUnban);
}
}
return true;
case "nameban":
case "banname":
if (usingIp)
{
msg("Please specify a name, not an ip.");
return true;
}
final String nameBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban nameBan = Ban.forPlayerName(username, sender, null, nameBanReason);
FUtil.adminAction(sender.getName(), "Banning IGN: " + username, true);
plugin.bm.addBan(nameBan);
if (player != null)
{
player.kickPlayer(nameBan.bakeKickMessage());
}
return true;
case "unbanname":
case "nameunban":
if (usingIp)
{
msg("Please specify a name, not an ip.");
return true;
}
FUtil.adminAction(sender.getName(), "Unbanning IGN: " + username, true);
plugin.bm.removeBan(plugin.bm.getByUsername(username));
return true;
case "banip":
case "ipban":
if (!usingIp)
{
msg("Please specify an IP.");
return true;
}
final String ipBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban ipBan = Ban.forPlayerIp(banIp, sender, null, ipBanReason);
plugin.bm.addBan(ipBan);
FUtil.adminAction(sender.getName(), "Banned an IP", true);
playerMsg(sender, ChatColor.GRAY + "Banned IP: " + banIp);
return true;
case "unbanip":
case "pardonip":
if (!usingIp)
{
msg("Please specify an IP.");
return true;
}
FUtil.adminAction(sender.getName(), "Unbanned an IP", true);
playerMsg(sender, ChatColor.GRAY + "Unbanned IP: " + banIp);
Ban ipUnban = plugin.bm.getByIp(banIp);
if (ipUnban != null)
{
plugin.bm.removeBan(ipUnban);
plugin.bm.unbanIp(banIp);
}
ipUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(banIp));
if (ipUnban != null)
{
plugin.bm.removeBan(ipUnban);
plugin.bm.unbanIp(banIp);
}
return true;
default:
return false;
}
}
}

View File

@ -3,7 +3,9 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -11,7 +13,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Kick the specified player.", usage = "/<command> <player> [reason]", aliases = "k")
@CommandParameters(description = "Kick the specified player.", usage = "/<command> <player> [reason] [-q]")
public class Command_kick extends FreedomCommand
{
@Override
@ -30,10 +32,24 @@ public class Command_kick extends FreedomCommand
return true;
}
boolean silent = false;
String reason = null;
if (args.length > 1)
if (args[args.length - 1].equalsIgnoreCase("-q"))
{
reason = StringUtils.join(args, " ", 1, args.length);
silent = true;
FLog.debug("silent");
if (args.length >= 2)
{
FLog.debug("set reason (silent)");
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else if (args.length > 1)
{
FLog.debug("set reason");
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
StringBuilder builder = new StringBuilder()
@ -43,11 +59,18 @@ public class Command_kick extends FreedomCommand
if (reason != null)
{
builder.append("\n").append(ChatColor.RED).append("Reason: ").append(ChatColor.GOLD).append(reason);
FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
}
else
if (!silent)
{
FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true);
if (reason != null)
{
FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
}
else
{
FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true);
}
}
player.kickPlayer(builder.toString());

View File

@ -47,7 +47,7 @@ public class Command_linkdiscord extends FreedomCommand
if (Discord.LINK_CODES.containsValue(data))
{
code = Discord.getCode(data);
code = plugin.dc.getCode(data);
}
else
{

View File

@ -0,0 +1,62 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Unbans the specified ip.", usage = "/<command> <ip> [-q]")
public class Command_unbanip extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
boolean silent = false;
String ip = args[0];
if (!FUtil.isValidIPv4(ip))
{
msg(ip + " is not a valid IP address", ChatColor.RED);
return true;
}
Ban ban = plugin.bm.getByIp(ip);
if (ban == null)
{
msg("The ip " + ip + " is not banned", ChatColor.RED);
return true;
}
if (ban.hasUsername())
{
msg("This ban is not an ip-only ban.");
return true;
}
if (args.length > 1 && args[1].equals("-q"))
{
silent = true;
}
plugin.bm.removeBan(ban);
if (!silent)
{
FUtil.adminAction(sender.getName(), "Unbanned the ip " + ip, true);
}
return true;
}
}

View File

@ -0,0 +1,56 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Unbans the specified name.", usage = "/<command> <name> [-q]")
public class Command_unbanname extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
boolean silent = false;
String name = args[0];
Ban ban = plugin.bm.getByUsername(name);
if (ban == null)
{
msg("The name " + name + " is not banned", ChatColor.RED);
return true;
}
if (ban.hasIps())
{
msg("This ban is not a name-only ban.");
return true;
}
if (args.length > 1 && args[1].equals("-q"))
{
silent = true;
}
plugin.bm.removeBan(ban);
if (!silent)
{
FUtil.adminAction(sender.getName(), "Unbanned the name " + name, true);
}
return true;
}
}

View File

@ -131,7 +131,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
return true;
}
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()))
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode())
{
msg(ChatColor.RED + "Host console is not allowed to use this command!");
return true;

View File

@ -161,7 +161,8 @@ public enum ConfigEntry
VOTING_INFO(List.class, "votinginfo"),
MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"),
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
TOGGLE_CHAT(Boolean.class, "toggle_chat");
TOGGLE_CHAT(Boolean.class, "toggle_chat"),
DEVELOPER_MODE(Boolean.class, "developer_mode");
//
private final Class<?> type;
private final String configName;

View File

@ -34,7 +34,7 @@ public class MainConfig extends FreedomService
}
public MainConfig(TotalFreedomMod plugin)
public MainConfig()
{
entries = new EnumMap<>(ConfigEntry.class);

View File

@ -26,6 +26,15 @@ public class FLog
log(Level.INFO, ex);
}
// Fuck spigot for not using log4j, we would of had a debug log level if they did
public static void debug(String message)
{
if (FUtil.inDeveloperMode())
{
log(Level.INFO, "\u001B[35m[TotalFreedomMod | DEBUG] " + message + "\u001B[0m", true);
}
}
// Level.WARNING:
public static void warning(String message)
{

View File

@ -126,6 +126,11 @@ public class FUtil
return FUtil.DEVELOPERS.contains(name);
}
public static boolean inDeveloperMode()
{
return ConfigEntry.DEVELOPER_MODE.getBoolean();
}
public static String formatName(String name)
{
return WordUtils.capitalizeFully(name.replace("_", " "));
@ -133,11 +138,7 @@ public class FUtil
public static String showS(int count)
{
if (count == 1)
{
return "";
}
return "s";
return (count == 1 ? "" : "s");
}
public static List<String> getPlayerList()
@ -760,6 +761,16 @@ public class FUtil
return Color.fromRGB((int) c1values[0], (int) c1values[1], (int) c1values[2]);
}
public static boolean isValidIPv4(String ip)
{
if (ip.matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$")
|| ip.matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([*])\\.([*])$"))
{
return true;
}
return false;
}
public static List<Color> createColorGradient(Color c1, Color c2, int steps)
{
double factor = 1.0 / (steps - 1.0);

View File

@ -486,3 +486,6 @@ autokick:
# Blocked Chat Codes - Use &code,&code2,&code3 (No spaces)
blocked_chatcodes: '&0,&k,&m,&n'
# Enables certain things like debug logs and console bypasses
developer_mode: false

View File

@ -2,6 +2,6 @@ name: TotalFreedomMod
main: me.totalfreedom.totalfreedommod.TotalFreedomMod
version: ${project.version}
description: Plugin for the Total Freedom server.
softdepend: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit]
softdepend: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit, WorldGuard, WorldGuardExtraFlags, TFGuilds]
authors: [Madgeek1450, Prozza]
api-version: 1.15
api-version: 1.16