diff --git a/appinfo.properties b/appinfo.properties index 12d186a4..71ad3419 100644 --- a/appinfo.properties +++ b/appinfo.properties @@ -1,5 +1,5 @@ -#Mon, 06 May 2013 21:59:49 +0200 +#Thu, 09 May 2013 15:32:18 +0200 program.VERSION=2.13 -program.BUILDNUM=160 -program.BUILDDATE=05/06/2013 09\:59 PM +program.BUILDNUM=182 +program.BUILDDATE=05/09/2013 03\:32 PM diff --git a/buildnumber.properties b/buildnumber.properties index 8beba18b..66869c73 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Mon May 06 21:59:49 CEST 2013 -build.number=161 +#Thu May 09 15:32:18 CEST 2013 +build.number=183 diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 11e07bc0..f4b24e3c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -23,6 +23,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.player.*; +import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -715,4 +716,16 @@ public class TFM_PlayerListener implements Listener { TFM_ServerInterface.handlePlayerLogin(event); } + + @EventHandler() + public void onServerPing(ServerListPingEvent event) + { + // Colorize :) + event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd())); + + if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress())) + { + event.setMotd(ChatColor.RED + "You are banned!"); + } + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java index e8ed4703..8d3612c4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java @@ -121,8 +121,6 @@ public class TFM_ServerInterface public static void handlePlayerLogin(PlayerLoginEvent event) { - // this should supersede all other onPlayerLogin authentication on the TFM server. - // when using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication. final Server server = TotalFreedomMod.plugin.getServer(); @@ -137,7 +135,8 @@ public class TFM_ServerInterface if (player_name.trim().length() <= 2) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is too short (must be at least 3 characters long)."); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, + "Your username is too short (must be at least 3 characters long)."); return; } else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find()) @@ -146,7 +145,8 @@ public class TFM_ServerInterface return; } - // not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() will return a null until after player login. + // not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() + // will return a null until after player login. boolean is_superadmin; if (server.getOnlineMode()) { @@ -165,13 +165,14 @@ public class TFM_ServerInterface { ban_entry = (BanEntry) banByName.getEntries().get(player_name.toLowerCase()); - String kick_message = "You are banned from this server."; + String kick_message = ChatColor.RED + "You are banned from this server."; if (ban_entry != null) { kick_message = kick_message + "\nReason: " + ban_entry.getReason(); if (ban_entry.getExpires() != null) { - kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires()); + kick_message = kick_message + "\nYour ban will be removed on " + + date_format.format(ban_entry.getExpires()); } } @@ -209,13 +210,14 @@ public class TFM_ServerInterface if (is_ip_banned) { - String kick_message = "Your IP address is banned from this server."; + String kick_message = ChatColor.RED + "Your IP address is banned from this server."; if (ban_entry != null) { kick_message = kick_message + "\nReason: " + ban_entry.getReason(); if (ban_entry.getExpires() != null) { - kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires()); + kick_message = kick_message + "\nYour ban will be removed on " + + date_format.format(ban_entry.getExpires()); } } @@ -227,7 +229,8 @@ public class TFM_ServerInterface { if (test_player.equalsIgnoreCase(player_name)) { - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server."); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + + "Your username is permanently banned from this server."); return; } } @@ -236,7 +239,8 @@ public class TFM_ServerInterface { if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4)) { - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server."); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + + "Your IP address is permanently banned from this server."); return; } } @@ -271,8 +275,21 @@ public class TFM_ServerInterface } } } - else - { + else // if user is superadmin + { + // force-allow superadmins to log in + event.allow(); + + if (isIPBanned(player_ip)) + { + unbanIP(player_ip); + } + + if (isNameBanned(player_name)) + { + unbanUsername(player_name); + } + for (Player test_player : server.getOnlinePlayers()) { if (test_player.getName().equalsIgnoreCase(player_name)) @@ -280,20 +297,23 @@ public class TFM_ServerInterface test_player.kickPlayer("An admin just logged in with the username you are using."); } } - - boolean can_kick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop. - while (server.getOnlinePlayers().length >= server.getMaxPlayers() && can_kick) + + if (server.getOnlinePlayers().length >= server.getMaxPlayers()) { - can_kick = false; - for (Player test_player : server.getOnlinePlayers()) + for (Player op : server.getOnlinePlayers()) { - if (!TFM_SuperadminList.isUserSuperadmin(test_player)) + if (!TFM_SuperadminList.isUserSuperadmin(op)) { - can_kick = true; - test_player.kickPlayer("You have been kicked to free up room for an admin."); - break; + op.kickPlayer("You have been kicked to free up space for an admin"); + return; } } + + // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop. + if (server.getOnlinePlayers().length >= server.getMaxPlayers()) + { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, this server is full"); + } } } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 3746910f..49163739 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -968,7 +968,8 @@ public class TFM_Util { if (TFM_SuperadminList.isUserSuperadmin(p)) { - p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ChatColor.WHITE + ": " + ChatColor.AQUA + message); + p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + + name + ": " + ChatColor.AQUA + message); } } } @@ -986,7 +987,8 @@ public class TFM_Util { prefix = ChatColor.GOLD + "(SA)"; } - if (sender.getName().equals("Madgeek1450") || sender.getName().equals("DarthSalamon")) + if (sender.getName().equalsIgnoreCase("Madgeek1450") + || sender.getName().equalsIgnoreCase("DarthSalamon")) { prefix = ChatColor.DARK_PURPLE + "(Dev)"; } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index a2c06f0a..35bd1d27 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -117,7 +117,8 @@ public class TotalFreedomMod extends JavaPlugin TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage()); } - TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon"); + TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon"); } @Override @@ -156,7 +157,8 @@ public class TotalFreedomMod extends JavaPlugin try { ClassLoader classLoader = TotalFreedomMod.class.getClassLoader(); - dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance(); + dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, + cmd.getName().toLowerCase())).newInstance(); dispatcher.setup(this, sender, dispatcher.getClass()); } catch (Throwable ex)