From 524d4da9d8cef9de9986de92766a4e49c2b9c661 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 1 Nov 2014 19:46:00 +0000 Subject: [PATCH 1/3] Bug Crunching on the ForceIP - Should work a lot better now. --- buildnumber.properties | 4 ++-- src/config.yml | 5 ++++- .../TotalFreedomMod/Config/TFM_ConfigEntry.java | 1 + .../Listener/TFM_PlayerListener.java | 14 ++++++++++++-- .../TotalFreedomMod/TFM_FrontDoor.java | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/buildnumber.properties b/buildnumber.properties index 23a75c6..d1aec97 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sat Nov 01 15:34:44 GMT 2014 -build.number=961 +#Sat Nov 01 19:44:24 GMT 2014 +build.number=963 diff --git a/src/config.yml b/src/config.yml index 9a658d2..771c6df 100644 --- a/src/config.yml +++ b/src/config.yml @@ -6,8 +6,11 @@ server: # You should change this to your server's name name: TotalFreedom - # The address your server is located at - Please include the port if required. + # The address your server is located at. Please do not include the port. address: play.totalfreedom.me + + # Please indicate your port. This should be 25565 unless otherwise indicated by your host + port: 25565 # Shown at the server list motd: TotalFreedom &8- Minecraft %mcversion% diff --git a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java index 7a69ee6..df22f16 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java +++ b/src/me/StevenLawson/TotalFreedomMod/Config/TFM_ConfigEntry.java @@ -30,6 +30,7 @@ public enum TFM_ConfigEntry SERVER_COLORFUL_MOTD(Boolean.class, "server.colorful_motd"), SERVER_NAME(String.class, "server.name"), SERVER_ADDRESS(String.class, "server.address"), + SERVER_PORT(Integer.class, "server.port"), SERVER_MOTD(String.class, "server.motd"), SERVER_OWNERS(List.class, "server.owners"), SERVER_BAN_URL(String.class, "server.ban_url"), diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index ddc772e..24af42a 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -37,6 +37,7 @@ public class TFM_PlayerListener implements Listener { private static final List BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ",")); private static final int MSG_PER_HEARTBEAT = 10; + public static int DEFAULT_PORT = 25565; @EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(PlayerInteractEvent event) @@ -858,9 +859,18 @@ public class TFM_PlayerListener implements Listener // Force IP Setup if(TFM_ConfigEntry.FORCE_IP_ENABLED.getBoolean()) { - if(!event.getHostname().equalsIgnoreCase(TFM_ConfigEntry.SERVER_ADDRESS.getString())) + if(!event.getHostname().equalsIgnoreCase(TFM_ConfigEntry.SERVER_ADDRESS.getString() + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger())) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString().replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString())); + if (TFM_ConfigEntry.SERVER_PORT.getInteger() != DEFAULT_PORT) + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString().replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString()) + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger()); + } + else + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString().replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString())); + + } + } } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java b/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java index 1251ec4..a4738f6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java @@ -481,7 +481,7 @@ public class TFM_FrontDoor { tempUrl = new URL("http://frontdoor.aws.af.cm/poll" + "?version=" + TotalFreedomMod.pluginVersion + "-" + TotalFreedomMod.buildCreator - + "&address=" + TFM_ConfigEntry.SERVER_ADDRESS.getString() + + "&address=" + TFM_ConfigEntry.SERVER_ADDRESS.getString() + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger() + "&name=" + TFM_ConfigEntry.SERVER_NAME.getString() + "&bukkitversion=" + Bukkit.getVersion()); } From 6f6fdb28bf7aa14be2a212f2a34673497aeb6f10 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 1 Nov 2014 19:51:43 +0000 Subject: [PATCH 2/3] Minor tweaks to default port, Heartbeat and blocked cmd's --- .../TotalFreedomMod/Listener/TFM_PlayerListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 24af42a..06f5219 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -35,9 +35,9 @@ import org.bukkit.util.Vector; public class TFM_PlayerListener implements Listener { - private static final List BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ",")); - private static final int MSG_PER_HEARTBEAT = 10; - public static int DEFAULT_PORT = 25565; + public static final List BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ",")); + public static final int MSG_PER_HEARTBEAT = 10; + public static final int DEFAULT_PORT = 25565; @EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(PlayerInteractEvent event) From 7fe0b562ee2fbc3902d7b84153fecd052a718c58 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 1 Nov 2014 19:55:45 +0000 Subject: [PATCH 3/3] Cleaned it up a bit as suggested by @jeromsar --- buildnumber.properties | 4 ++-- .../Listener/TFM_PlayerListener.java | 18 ++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/buildnumber.properties b/buildnumber.properties index d1aec97..80fe27d 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sat Nov 01 19:44:24 GMT 2014 -build.number=963 +#Sat Nov 01 19:54:24 GMT 2014 +build.number=964 diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 06f5219..da1b41f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -856,21 +856,15 @@ public class TFM_PlayerListener implements Listener { TFM_ServerInterface.handlePlayerLogin(event); - // Force IP Setup + // Force IP Setup if(TFM_ConfigEntry.FORCE_IP_ENABLED.getBoolean()) { if(!event.getHostname().equalsIgnoreCase(TFM_ConfigEntry.SERVER_ADDRESS.getString() + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger())) - { - if (TFM_ConfigEntry.SERVER_PORT.getInteger() != DEFAULT_PORT) - { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString().replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString()) + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger()); - } - else - { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString().replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString())); - - } - + { + final int port = TFM_ConfigEntry.SERVER_PORT.getInteger(); + + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, TFM_ConfigEntry.FORCE_IP_KICKMSG.getString().replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString()) + (port == DEFAULT_PORT ? "" : ":" + port)); + } } }