Added the ForceIP feature - Resolves #224

This commit is contained in:
Ryan
2014-10-31 17:47:05 +00:00
parent 5c50069f21
commit 57a6b35457
4 changed files with 35 additions and 3 deletions

View File

@ -4,6 +4,9 @@ import java.util.List;
public enum TFM_ConfigEntry
{
FORCE_IP_ENABLED(Boolean.class, "forceip.enabled"),
FORCE_IP_KICKMSG(String.class, "forceip.kickmsg"),
//
ALLOW_EXPLOSIONS(Boolean.class, "allow.explosions"),
ALLOW_FIRE_PLACE(Boolean.class, "allow.fire_place"),
ALLOW_FIRE_SPREAD(Boolean.class, "allow.fire_spread"),
@ -31,6 +34,8 @@ public enum TFM_ConfigEntry
SERVER_OWNERS(List.class, "server.owners"),
SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_PERMBAN_URL(String.class, "server.permban_url"),
SERVER_HOSTNAME(String.class, "server.hostname"),
SERVER_PORT(Integer.class, "server.port"),
//
TWITTERBOT_ENABLED(Boolean.class, "twitterbot.enabled"),
TWITTERBOT_SECRET(String.class, "twitterbot.secret"),

View File

@ -766,6 +766,7 @@ public class TFM_PlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
final String ip = TFM_Util.getIp(player);
final TFM_Player playerEntry;
@ -853,6 +854,14 @@ public class TFM_PlayerListener implements Listener
public void onPlayerLogin(PlayerLoginEvent event)
{
TFM_ServerInterface.handlePlayerLogin(event);
// Force IP Setup
if(TFM_ConfigEntry.FORCE_IP_ENABLED.getBoolean()){
if(!event.getHostname().equalsIgnoreCase(TFM_ConfigEntry.SERVER_HOSTNAME.getString() + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger())){
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString());
}
}
}
// Player Tab and auto Tags