Added config values for MOTD, server name and address. Resolves #178

This commit is contained in:
unknown 2014-05-16 15:18:24 +02:00
parent 16b02e3dec
commit 67c86aea24
7 changed files with 68 additions and 18 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Wed May 14 16:21:24 CEST 2014 #Fri May 16 15:17:03 CEST 2014
build.number=848 build.number=855

View File

@ -1,6 +1,26 @@
# TotalFreedomMod v4.2 Configuration # TotalFreedomMod v4.2 Configuration
# by Madgeek1450 and DarthSalamon # by Madgeek1450 and DarthSalamon
# Generic server information
server:
# You should change this to your server's name
name: TotalFreedom
# The address your server is located at
address: 64.34.165.5:28965
# Shown at the server list
motd: TotalFreedom &8- Minecraft %mcversion%
# Every word in the MOTD will be a different color unless prefixed by a color code
colorful_motd: true
# URL players should appeal for bans at
ban_url: http://totalfreedom.boards.net/
# URL players should appeal for permanent bans at
permban_url: http://bit.ly/TF_PermBan
# Blocking certain events # Blocking certain events
allow: allow:
fire_place: false fire_place: false

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList; import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager; import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker; import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
@ -57,6 +58,7 @@ public class Command_tfm extends TFM_Command
TotalFreedomMod.buildNumber, TotalFreedomMod.buildNumber,
TotalFreedomMod.buildDate, TotalFreedomMod.buildDate,
TotalFreedomMod.buildCreator), ChatColor.GOLD); TotalFreedomMod.buildCreator), ChatColor.GOLD);
playerMsg("Running on " + TFM_ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
playerMsg("Created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD); playerMsg("Created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
playerMsg("Visit " + ChatColor.AQUA + "http://totalfreedom.me/" + ChatColor.GREEN + " for more information.", ChatColor.GREEN); playerMsg("Visit " + ChatColor.AQUA + "http://totalfreedom.me/" + ChatColor.GREEN + " for more information.", ChatColor.GREEN);

View File

@ -34,6 +34,7 @@ public enum TFM_ConfigEntry
HTTPD_ENABLED(Boolean.class, "httpd.enabled"), HTTPD_ENABLED(Boolean.class, "httpd.enabled"),
AUTOKICK_ENABLED(Boolean.class, "autokick.enabled"), AUTOKICK_ENABLED(Boolean.class, "autokick.enabled"),
CONSOLE_IS_SENIOR(Boolean.class, "console_is_senior"), CONSOLE_IS_SENIOR(Boolean.class, "console_is_senior"),
SERVER_COLORFUL_MOTD(Boolean.class, "server.colorful_motd"),
// //
AUTO_PROTECT_RADIUS(Double.class, "protectarea.auto_protect_radius"), AUTO_PROTECT_RADIUS(Double.class, "protectarea.auto_protect_radius"),
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"), EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),
@ -54,6 +55,11 @@ public enum TFM_ConfigEntry
TWITTERBOT_SECRET(String.class, "twitterbot.secret"), TWITTERBOT_SECRET(String.class, "twitterbot.secret"),
TWITTERBOT_URL(String.class, "twitterbot.url"), TWITTERBOT_URL(String.class, "twitterbot.url"),
HTTPD_PUBLIC_FOLDER(String.class, "httpd.public_folder"), HTTPD_PUBLIC_FOLDER(String.class, "httpd.public_folder"),
SERVER_NAME(String.class, "server.name"),
SERVER_ADDRESS(String.class, "server.address"),
SERVER_MOTD(String.class, "server.motd"),
SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_PERMBAN_URL(String.class, "server.permban_url"),
// //
BLOCKED_COMMANDS(List.class, "blocked_commands"), BLOCKED_COMMANDS(List.class, "blocked_commands"),
HOST_SENDER_NAMES(List.class, "host_sender_names"), HOST_SENDER_NAMES(List.class, "host_sender_names"),

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry; import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager; import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
@ -10,8 +9,6 @@ import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
public class TFM_ServerListener implements Listener public class TFM_ServerListener implements Listener
@ -55,25 +52,46 @@ public class TFM_ServerListener implements Listener
public void onServerPing(ServerListPingEvent event) public void onServerPing(ServerListPingEvent event)
{ {
final String ip = event.getAddress().getHostAddress(); final String ip = event.getAddress().getHostAddress();
event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY + "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion());
if (TFM_BanManager.getInstance().isIpBanned(ip)) if (TFM_BanManager.getInstance().isIpBanned(ip))
{ {
event.setMotd(ChatColor.RED + "You are banned."); event.setMotd(ChatColor.RED + "You are banned.");
return;
} }
else if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
event.setMotd(ChatColor.RED + "Server is closed."); event.setMotd(ChatColor.RED + "Server is closed.");
return;
} }
else if (Bukkit.hasWhitelist())
if (Bukkit.hasWhitelist())
{ {
event.setMotd(ChatColor.RED + "Whitelist enabled."); event.setMotd(ChatColor.RED + "Whitelist enabled.");
return;
} }
else if (Bukkit.getOnlinePlayers().length >= Bukkit.getMaxPlayers())
if (Bukkit.getOnlinePlayers().length >= Bukkit.getMaxPlayers())
{ {
event.setMotd(ChatColor.RED + "Server is full."); event.setMotd(ChatColor.RED + "Server is full.");
return;
} }
if (!TFM_ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
{
event.setMotd(TFM_Util.colorize(TFM_ConfigEntry.SERVER_MOTD.getString()
.replace("%mcversion%", TFM_ServerInterface.getVersion())));
return;
}
// Colorful MOTD
final StringBuilder motd = new StringBuilder();
for (String word : TFM_ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", TFM_ServerInterface.getVersion()).split(" "))
{
motd.append(TFM_Util.randomChatColor()).append(word).append(" ");
}
event.setMotd(TFM_Util.colorize(motd.toString()));
} }
} }

View File

@ -480,9 +480,9 @@ public class TFM_FrontDoor
try try
{ {
tempUrl = new URL("http://frontdoor.aws.af.cm/" tempUrl = new URL("http://frontdoor.aws.af.cm/"
+ "?version=" + TotalFreedomMod.pluginVersion + "?version=" + TotalFreedomMod.pluginVersion + "-" + TotalFreedomMod.buildCreator
+ "&port=" + TotalFreedomMod.server.getPort() + "&address=" + TFM_ConfigEntry.SERVER_ADDRESS.getString()
+ "&name=" + (Bukkit.getServerName().length() > 3 ? Bukkit.getServerName() : Bukkit.getServer().getMotd()) + "&name=" + TFM_ConfigEntry.SERVER_NAME.getString()
+ "&bukkitversion=" + Bukkit.getVersion()); + "&bukkitversion=" + Bukkit.getVersion());
} }
catch (MalformedURLException ex) catch (MalformedURLException ex)

View File

@ -106,7 +106,8 @@ public class TFM_ServerInterface
{ {
final TFM_Ban ban = banManager.getByUuid(uuid); final TFM_Ban ban = banManager.getByUuid(uuid);
String kickMessage = ChatColor.RED + "You are temporarily banned from this server.\nAppeal at http://totalfreedom.boards.net/."; String kickMessage = ChatColor.RED + "You are temporarily banned from this server."
+ "\nAppeal at " + ChatColor.GOLD + TFM_ConfigEntry.SERVER_BAN_URL.getString();
if (!ban.getReason().equals("none")) if (!ban.getReason().equals("none"))
{ {
@ -126,7 +127,8 @@ public class TFM_ServerInterface
{ {
final TFM_Ban ban = banManager.getByIp(ip); final TFM_Ban ban = banManager.getByIp(ip);
String kickMessage = ChatColor.RED + "Your IP address is temporarily banned from this server.\nAppeal at http://totalfreedom.boards.net/."; String kickMessage = ChatColor.RED + "Your IP address is temporarily banned from this server."
+ "\nAppeal at " + ChatColor.GOLD + TFM_ConfigEntry.SERVER_BAN_URL.getString();
if (!ban.getReason().equals("none")) if (!ban.getReason().equals("none"))
{ {
@ -148,7 +150,8 @@ public class TFM_ServerInterface
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4)) if (TFM_Util.fuzzyIpMatch(testIp, ip, 4))
{ {
event.disallow(Result.KICK_OTHER, event.disallow(Result.KICK_OTHER,
ChatColor.RED + "Your IP address is permanently banned from this server.\nRelease procedures are available at http://bit.ly/TF_PermBan"); ChatColor.RED + "Your IP address is permanently banned from this server.\nRelease procedures are available at\n"
+ ChatColor.GOLD + TFM_ConfigEntry.SERVER_PERMBAN_URL);
return; return;
} }
} }
@ -159,7 +162,8 @@ public class TFM_ServerInterface
if (testPlayer.equalsIgnoreCase(username)) if (testPlayer.equalsIgnoreCase(username))
{ {
event.disallow(Result.KICK_OTHER, event.disallow(Result.KICK_OTHER,
ChatColor.RED + "Your username is permanently banned from this server.\nRelease procedures are available at http://bit.ly/TF_PermBan"); ChatColor.RED + "Your username is permanently banned from this server.\nRelease procedures are available at\n"
+ ChatColor.GOLD + TFM_ConfigEntry.SERVER_PERMBAN_URL);
return; return;
} }
} }