mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
Fixed last bugs with ForceIP. Closes #354
This commit is contained in:
parent
49f6879ccb
commit
9970277134
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Thu Nov 13 19:22:09 CET 2014
|
||||
build.number=953
|
||||
#Thu Nov 13 21:12:26 CET 2014
|
||||
build.number=957
|
||||
|
@ -8,9 +8,6 @@ server:
|
||||
|
||||
# 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%
|
||||
@ -27,15 +24,16 @@ server:
|
||||
|
||||
# URL players should appeal for permanent bans at
|
||||
permban_url: http://bit.ly/TF_PermBan
|
||||
|
||||
# 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 %address%
|
||||
# ForceIP configuration
|
||||
forceip:
|
||||
enabled: false
|
||||
|
||||
# The port players should use to connect to your server; only applies to forceip
|
||||
port: 25565
|
||||
|
||||
# The kick message sent to players when logging in with the wrong hostname
|
||||
kickmsg: You have been kicked from the server - Please connect using %address%
|
||||
|
||||
|
||||
# Blocking certain events
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
public enum TFM_ConfigEntry
|
||||
{
|
||||
FORCE_IP_ENABLED(Boolean.class, "forceip.enabled"),
|
||||
FORCE_IP_PORT(Integer.class, "forceip.port"),
|
||||
FORCE_IP_KICKMSG(String.class, "forceip.kickmsg"),
|
||||
//
|
||||
ALLOW_EXPLOSIONS(Boolean.class, "allow.explosions"),
|
||||
@ -30,7 +31,6 @@ 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"),
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
|
||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@ -11,7 +9,9 @@ import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.*;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.Command_landmine;
|
||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.RollbackEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
|
||||
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -767,7 +767,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;
|
||||
@ -833,50 +833,8 @@ public class TFM_PlayerListener implements Listener
|
||||
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.lockdownEnabled)
|
||||
{
|
||||
TFM_Util.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 20L * 3L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
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_ADDRESS.getString() + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger()))
|
||||
{
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player Tab and auto Tags
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public static void onPlayerJoinEvent(PlayerJoinEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
//TODO: Cleanup
|
||||
String name = player.getName();
|
||||
|
||||
if (TFM_Util.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
name = ChatColor.DARK_PURPLE + name;
|
||||
@ -905,5 +863,45 @@ public class TFM_PlayerListener implements Listener
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.lockdownEnabled)
|
||||
{
|
||||
TFM_Util.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 20L * 3L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
if (TFM_ConfigEntry.FORCE_IP_ENABLED.getBoolean())
|
||||
{
|
||||
final String hostname = event.getHostname();
|
||||
final String connectAddress = TFM_ConfigEntry.SERVER_ADDRESS.getString();
|
||||
final int connectPort = TotalFreedomMod.server.getPort();
|
||||
|
||||
if (!hostname.equalsIgnoreCase(connectAddress + ":" + connectPort) && !hostname.equalsIgnoreCase(connectAddress + ".:" + connectPort))
|
||||
{
|
||||
final int forceIpPort = TFM_ConfigEntry.FORCE_IP_PORT.getInteger();
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||
TFM_ConfigEntry.FORCE_IP_KICKMSG.getString()
|
||||
.replace("%address%", TFM_ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TFM_ServerInterface.handlePlayerLogin(event);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_MainConfig;
|
||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
@ -14,6 +12,8 @@ import me.StevenLawson.TotalFreedomMod.Commands.Command_trail;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.Config.TFM_MainConfig;
|
||||
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -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() + ":" + TFM_ConfigEntry.SERVER_PORT.getInteger()
|
||||
+ "&address=" + TFM_ConfigEntry.SERVER_ADDRESS.getString() + ":" + TotalFreedomMod.server.getPort()
|
||||
+ "&name=" + TFM_ConfigEntry.SERVER_NAME.getString()
|
||||
+ "&bukkitversion=" + Bukkit.getVersion());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user