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

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sat Aug 30 16:14:15 CEST 2014
build.number=949
#Build Number for ANT. Do not edit!
#Fri Oct 31 17:39:33 GMT 2014
build.number=959

View file

@ -1,6 +1,8 @@
# TotalFreedomMod v4.3 Configuration
# by Madgeek1450 and DarthSalamon
# Generic server information
server:
# You should change this to your server's name
@ -24,6 +26,22 @@ server:
# URL players should appeal for permanent bans at
permban_url: http://bit.ly/TF_PermBan
# Your Servers Host Name - Used for ForceIP
hostname: play.totalfreedom.me
# Server Port - Used for ForceIP
port: 25565
# ForceIP Configuration
forceip:
# Please state if you wish to enable the ForceIP system.
enabled: true
# Please enter the kick message you wish for people to see if they are not connecting on the servers hostname
kickmsg: You have been kicked from the server - Please connect using play.totalfreedom.me
# Blocking certain events
allow:

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