@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.bukkit.configuration.InvalidConfigurationException;
@@ -81,8 +82,8 @@ public void save()
}
catch (Exception ex)
{
plugin.getLogger().severe("Could not save configuration file: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
TFM_Log.severe("Could not save configuration file: " + configFile.getName());
TFM_Log.severe(ExceptionUtils.getStackTrace(ex));
}
}

@@ -108,10 +109,10 @@ public void load()
}
catch (IOException ex)
{
plugin.getLogger().severe("Could not write default configuration file: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
TFM_Log.severe("Could not write default configuration file: " + configFile.getName());
TFM_Log.severe(ExceptionUtils.getStackTrace(ex));
}
plugin.getLogger().info("Installed default configuration " + configFile.getName());
TFM_Log.info("Installed default configuration " + configFile.getName());
}

super.addDefaults(getDefaultConfig());
@@ -122,10 +123,10 @@ public void load()
super.load(configFile);
}
}
catch (Exception ex)
catch (IOException | InvalidConfigurationException ex)
{
plugin.getLogger().severe("Could not load configuration file: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
TFM_Log.severe("Could not load configuration file: " + configFile.getName());
TFM_Log.severe(ExceptionUtils.getStackTrace(ex));
}
}

@@ -144,6 +145,7 @@ public YamlConfiguration getConfig()
* Returns the default configuration as been stored in the jar-file of the owning plugin.
* @return The default configuration.
*/
@SuppressWarnings("ConvertToTryWithResources")
public YamlConfiguration getDefaultConfig()
{
final YamlConfiguration DEFAULT_CONFIG = new YamlConfiguration();
@@ -153,16 +155,10 @@ public YamlConfiguration getDefaultConfig()
DEFAULT_CONFIG.load(isr);
isr.close();
}
catch (IOException ex)
{
plugin.getLogger().severe("Could not load default configuration: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
return null;
}
catch (InvalidConfigurationException ex)
catch (IOException | InvalidConfigurationException ex)
{
plugin.getLogger().severe("Could not load default configuration: " + configFile.getName());
plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex));
TFM_Log.severe("Could not load default configuration: " + configFile.getName());
TFM_Log.severe(ExceptionUtils.getStackTrace(ex));
return null;
}
return DEFAULT_CONFIG;
@@ -13,6 +13,7 @@
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;

@SuppressWarnings("ConvertToTryWithResources")
public class TFM_MainConfig
{
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.CONFIG_FILENAME);
@@ -92,11 +93,7 @@ public static void load()
{
TFM_Log.severe(ex);
}
catch (IOException ex)
{
TFM_Log.severe(ex);
}
catch (InvalidConfigurationException ex)
catch (IOException | InvalidConfigurationException ex)
{
TFM_Log.severe(ex);
}
@@ -285,11 +282,7 @@ private TFM_Defaults(InputStream defaultConfig)
defaults.load(isr);
isr.close();
}
catch (IOException ex)
{
TFM_Log.severe(ex);
}
catch (InvalidConfigurationException ex)
catch (IOException | InvalidConfigurationException ex)
{
TFM_Log.severe(ex);
}
@@ -9,6 +9,7 @@
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.Commands.Command_landmine;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.FOPM_TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
@@ -723,13 +724,40 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
event.setCancelled(true);
}

if (command.contains("175:") || command.contains("double_plant:"))
{
event.setCancelled(true);
TFM_Util.autoEject(player, ChatColor.DARK_RED + "Do not attempt to use any command involving the crash item!");
}

ChatColor colour = ChatColor.GRAY;
if (command.contains("//"))
{
colour = ChatColor.RED;
}
if (!TFM_AdminList.isSuperAdmin(player))
{
for (Player pl : Bukkit.getOnlinePlayers())
{
if (TFM_AdminList.isSuperAdmin(pl) && TFM_PlayerData.getPlayerData(pl).cmdspyEnabled())
{
TFM_Util.playerMsg(pl, player.getName() + ": " + command);
if (!command.contains("purple") && !command.contains("deop") && !command.contains("ban") && !command.contains("unban") && !command.contains("optroll") && !command.contains("blowup"))
{
TFM_Util.playerMsg(pl, colour + player.getName() + ": " + command);
}
}
}
}
else
{
for (Player pl : Bukkit.getOnlinePlayers())
{
if (FOPM_TFM_Util.isHighRank(pl) && TFM_PlayerData.getPlayerData(pl).cmdspyEnabled() && player != pl)
{
if (!command.contains("purple") && !command.contains("deop") && !command.contains("ban") && !command.contains("unban") && !command.contains("optroll") && !command.contains("blowup"))
{
TFM_Util.playerMsg(pl, colour + player.getName() + ": " + command);
}
}
}
}
@@ -843,12 +871,21 @@ public void onPlayerJoin(PlayerJoinEvent event)
// Handle admin impostors
if (TFM_AdminList.isAdminImpostor(player))
{
TFM_Util.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
player.getInventory().clear();
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
TFM_PlayerData.getPlayerData(player).setFrozen(true);
if (TFM_Util.imposters.contains(player.getName()))
{
TFM_Util.bcastMsg("Warning: " + player.getName() + " is not an imposter and is just trolling.", ChatColor.RED);
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is a fake " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor");
}
else
{
TFM_Util.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
player.getInventory().clear();
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
TFM_PlayerData.getPlayerData(player).setFrozen(true);
TFM_Util.bcastMsg("Admins, tell him to verify!", ChatColor.RED);
}
}
else if (TFM_AdminList.isSuperAdmin(player) || TFM_Util.DEVELOPERS.contains(player.getName()))
{
@@ -654,6 +654,10 @@ public static boolean checkPartialSuperadminIp(String ip, String name)

public static boolean isAdminImpostor(Player player)
{
if (TFM_Util.imposters.contains(player.getName()))
{
return true;
}
if (superUUIDs.contains(TFM_UuidManager.getUniqueId(player)))
{
return !isSuperAdmin(player);
@@ -0,0 +1,15 @@
package me.StevenLawson.TotalFreedomMod;

import java.util.Arrays;
import java.util.List;

public class TFM_HardcodeBanList {

// All of these are permabans that load automatically //
public static final List<String> HARDCODE = Arrays.asList(
"ExamplePlayer"
);
public static final List<String> HARDCODE_IPS = Arrays.asList(
"0.0.*.*"
);
}
@@ -160,7 +160,7 @@ public static void handlePlayerLogin(PlayerLoginEvent event)

if (count >= server.getMaxPlayers())
{
event.disallow(Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
event.disallow(Result.KICK_OTHER, "UnlimitedFreedom is full and a player could not be kicked, sorry!");
return;
}

@@ -171,21 +171,21 @@ public static void handlePlayerLogin(PlayerLoginEvent event)
// Server full check
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
{
event.disallow(Result.KICK_FULL, "Sorry, but this server is full.");
event.disallow(Result.KICK_FULL, "Sorry, but UnlimitedFreedom is full.");
return;
}

// Admin-only mode
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{
event.disallow(Result.KICK_OTHER, "Server is temporarily open to admins only.");
event.disallow(Result.KICK_OTHER, "UnlimitedFreedom is temporarily open to admins only.");
return;
}

// Lockdown mode
if (TotalFreedomMod.lockdownEnabled)
{
event.disallow(Result.KICK_OTHER, "Server is currently in lockdown mode.");
event.disallow(Result.KICK_OTHER, "UnlimitedFreedom is currently in lockdown mode.");
return;
}

@@ -194,7 +194,7 @@ public static void handlePlayerLogin(PlayerLoginEvent event)
{
if (!getWhitelisted().contains(username.toLowerCase()))
{
event.disallow(Result.KICK_OTHER, "You are not whitelisted on this server.");
event.disallow(Result.KICK_OTHER, "You are not whitelisted on this server!");
return;
}
}
@@ -234,11 +234,27 @@ public static void handlePlayerLogin(PlayerLoginEvent event)
if (testPlayer.equalsIgnoreCase(username))
{
event.disallow(Result.KICK_OTHER,
ChatColor.RED + "Your username is permanently banned from this server.\n"
ChatColor.RED + "Your username is permanently banned from UnlimitedFreedom.\n"
+ "Release procedures are available at\n"
+ ChatColor.GOLD + TFM_ConfigEntry.SERVER_PERMBAN_URL.getString());
return;
}
}

for (String testPlayer : TFM_Util.permbannedNames) {
if (testPlayer.equalsIgnoreCase(username)) {
event.disallow(Result.KICK_OTHER,
ChatColor.RED + "You have been hardcoded to a permban list, fuck off you twat.");
return;
}
}

for (String testIp : TFM_Util.permbannedIps) {
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4)) {
event.disallow(Result.KICK_OTHER,
ChatColor.RED + "You have been hardcoded to a permban list, fuck off you twat.");
return;
}
}
}
}
@@ -32,6 +32,8 @@
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.Config.TFM_Config;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import static me.StevenLawson.TotalFreedomMod.TFM_HardcodeBanList.HARDCODE;
import static me.StevenLawson.TotalFreedomMod.TFM_HardcodeBanList.HARDCODE_IPS;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
@@ -85,6 +87,9 @@
ChatColor.RED,
ChatColor.LIGHT_PURPLE,
ChatColor.YELLOW);
public static ArrayList<String> imposters = new ArrayList<>();
public static final List<String> permbannedNames = HARDCODE;
public static final List<String> permbannedIps = HARDCODE_IPS;

static
{
@@ -4,7 +4,6 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -46,13 +45,10 @@ public class TotalFreedomMod extends JavaPlugin
public static final String PROTECTED_AREA_FILENAME = "protectedareas.dat";
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
//
public static final BuildProperties build = new BuildProperties();
@Deprecated
public static final String YOU_ARE_NOT_OP = me.StevenLawson.TotalFreedomMod.Commands.TFM_Command.YOU_ARE_NOT_OP;
//
public static String buildNumber = "1";
public static String buildDate = TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date());
public static String buildCreator = "AwesomePinch";
//
public static Server server;
public static TotalFreedomMod plugin;
public static String pluginName;
@@ -72,14 +68,15 @@ public void onLoad()
TFM_Log.setPluginLogger(plugin.getLogger());
TFM_Log.setServerLogger(server.getLogger());

setAppProperties();
build.load();
}

@Override
public void onEnable()
{
TFM_Log.info("Made by Madgeek1450 and Prozza");
TFM_Log.info("Compiled " + buildDate + " by " + buildCreator);
TFM_Log.info("Created by Madgeek1450 and Prozza");
TFM_Log.info("Version " + build.formattedVersion());
TFM_Log.info("Compiled " + build.date + " by " + build.builder);

final TFM_Util.MethodTimer timer = new TFM_Util.MethodTimer();
timer.start();
@@ -217,25 +214,36 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
return TFM_CommandHandler.handleCommand(sender, cmd, commandLabel, args);
}

private static void setAppProperties()
{
try
{
final InputStream in = plugin.getResource("appinfo.properties");
Properties props = new Properties();
public static class BuildProperties {
public String builder;
public String number;
public String head;
public String date;

public void load() {
try
{
final InputStream in = plugin.getResource("build.properties");

final Properties props = new Properties();
props.load(in);
in.close();

// in = plugin.getClass().getResourceAsStream("/appinfo.properties");
props.load(in);
in.close();
builder = props.getProperty("program.builder", "unknown");
number = props.getProperty("program.buildnumber", "1");
head = props.getProperty("program.buildhead", "unknown");
date = props.getProperty("program.builddate", "unknown");

TotalFreedomMod.buildNumber = props.getProperty("program.buildnumber");
TotalFreedomMod.buildDate = props.getProperty("program.builddate");
TotalFreedomMod.buildCreator = props.getProperty("program.buildcreator");
}
catch (Exception ex)
{
TFM_Log.severe("Could not load build properties! Did you compile with Netbeans/ANT?");
TFM_Log.severe(ex);
}
}
catch (Exception ex)
{
TFM_Log.severe("Could not load App properties!");
TFM_Log.severe(ex);

public String formattedVersion() {
return pluginVersion + "." + number + " (" + head + ")";
}
}
}
@@ -1,8 +1,8 @@
name: UnlimitedFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 4.3
version: 2.0
description: Plugin for the UnlimitedFreedom server.
softdepend: [BukkitTelnet, WorldEdit, Essentials]
authors: [Madgeek1450, Prozza]
authors: [Madgeek1450, Prozza, tylerhyperHD, AwesomePinch]

# plugin.yml is no longer used to define commands.