mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Removed need to have a modified CraftBukkit
This commit is contained in:
parent
039de8ba88
commit
8b601f1e70
@ -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
|
||||
|
@ -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
|
||||
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
@ -281,18 +298,21 @@ public class TFM_ServerInterface
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)";
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user