Added unbannable usernames (defined in config)

Changed all raw Lists in config to StringLists
This commit is contained in:
JeromSar 2013-08-24 21:35:09 +02:00
parent 143b323854
commit d71b043102
9 changed files with 64 additions and 17 deletions

View File

@ -1,5 +1,5 @@
#Fri, 23 Aug 2013 21:18:29 -0400 #Sat, 24 Aug 2013 21:25:38 +0200
program.VERSION=3.1 program.VERSION=3.1
program.BUILDNUM=479 program.BUILDNUM=481
program.BUILDDATE=08/23/2013 09\:18 PM program.BUILDDATE=08/24/2013 09\:25 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Fri Aug 23 21:18:29 EDT 2013 #Sat Aug 24 21:25:38 CEST 2013
build.number=480 build.number=482

View File

@ -124,6 +124,37 @@ host_sender_names:
- rcon - rcon
- remotebukkit - remotebukkit
# Players who cannot be banned by username
unbannable_usernames:
- honeydew
- xephos
- captainsparklez
- truemu
- kiershar
- fvdisco
- sethbling
- notch
- jeb_
- gamechap
- bertiechap
- vechs
- antvenom
- chimneyswift
- deadmau5
- etho
- skydoesminecraft
- tobyturner
- xxslyfoxhoundxx
- paulsoaresjr
- sips_
- deadlox
- xxslyxx
- jeromeasf
- dinnerbone
- grumm
- cavemanfilms
# TwitterBot - Used to allow superadmins to verify themselves using twitter # TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot_enabled: false twitterbot_enabled: false
twitterbot_url: '' twitterbot_url: ''

View File

@ -33,7 +33,7 @@ public class TFM_CommandBlocker
return; return;
} }
List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList(); List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getStringList();
for (String rawEntry : _blockedCommands) for (String rawEntry : _blockedCommands)
{ {
String[] parts = rawEntry.split(":"); String[] parts = rawEntry.split(":");

View File

@ -189,7 +189,7 @@ public class TFM_Config
} }
} }
public List getList(TFM_ConfigEntry entry) public List<String> getStringList(TFM_ConfigEntry entry)
{ {
try try
{ {

View File

@ -49,7 +49,8 @@ public enum TFM_ConfigEntry
TWITTERBOT_URL(String.class, "twitterbot_url"), TWITTERBOT_URL(String.class, "twitterbot_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"),
UNBANNABLE_USERNAMES(List.class, "unbannable_usernames");
// //
private final Class<?> type; private final Class<?> type;
private final String configName; private final String configName;
@ -114,8 +115,8 @@ public enum TFM_ConfigEntry
return value; return value;
} }
public List getList() public List<String> getStringList()
{ {
return TFM_Config.getInstance().getList(this); return TFM_Config.getInstance().getStringList(this);
} }
} }

View File

@ -14,7 +14,7 @@ public class TFM_Log
throw new AssertionError(); throw new AssertionError();
} }
//Level.INFO: // Level.INFO:
public static void info(String message) public static void info(String message)
{ {
info(message, false); info(message, false);
@ -30,7 +30,7 @@ public class TFM_Log
log(Level.INFO, ex); log(Level.INFO, ex);
} }
//Level.WARNING: // Level.WARNING:
public static void warning(String message) public static void warning(String message)
{ {
info(message, false); info(message, false);
@ -46,7 +46,7 @@ public class TFM_Log
log(Level.WARNING, ex); log(Level.WARNING, ex);
} }
//Level.SEVERE: // Level.SEVERE:
public static void severe(String message) public static void severe(String message)
{ {
info(message, false); info(message, false);
@ -62,7 +62,7 @@ public class TFM_Log
log(Level.SEVERE, ex); log(Level.SEVERE, ex);
} }
//Utility // Utility
private static void log(Level level, String message, boolean raw) private static void log(Level level, String message, boolean raw)
{ {
getLogger(raw).log(level, message); getLogger(raw).log(level, message);

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.minecraft.server.v1_6_R2.BanEntry; import net.minecraft.server.v1_6_R2.BanEntry;
@ -50,6 +51,22 @@ public class TFM_ServerInterface
public static void banUsername(String name, String reason, String source, Date expire_date) public static void banUsername(String name, String reason, String source, Date expire_date)
{ {
name = name.toLowerCase().trim(); name = name.toLowerCase().trim();
if (TFM_SuperadminList.getSuperadminNames().contains(name))
{
TFM_Log.info("Not banning username " + name + ": is superadmin");
return;
}
for (String username : TFM_ConfigEntry.UNBANNABLE_USERNAMES.getStringList())
{
if (username.toLowerCase().trim().equals(name))
{
TFM_Log.info("Not banning username " + name + ": is unbannable as defined in config.");
return;
}
}
BanEntry ban_entry = new BanEntry(name); BanEntry ban_entry = new BanEntry(name);
if (expire_date != null) if (expire_date != null)
{ {
@ -110,7 +127,6 @@ public class TFM_ServerInterface
return ipBans.getEntries().containsKey(ip); return ipBans.getEntries().containsKey(ip);
} }
@SuppressWarnings("rawtypes")
public static int purgeWhitelist() public static int purgeWhitelist()
{ {
Set whitelisted = MinecraftServer.getServer().getPlayerList().getWhitelisted(); Set whitelisted = MinecraftServer.getServer().getPlayerList().getWhitelisted();
@ -181,7 +197,6 @@ public class TFM_ServerInterface
boolean is_ip_banned = false; boolean is_ip_banned = false;
@SuppressWarnings("rawtypes")
Iterator ip_bans = banByIP.getEntries().keySet().iterator(); Iterator ip_bans = banByIP.getEntries().keySet().iterator();
while (ip_bans.hasNext()) while (ip_bans.hasNext())
{ {

View File

@ -746,7 +746,7 @@ public class TFM_Util
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static boolean isFromHostConsole(String sender_name) public static boolean isFromHostConsole(String sender_name)
{ {
return ((List<String>) TFM_ConfigEntry.HOST_SENDER_NAMES.getList()).contains(sender_name.toLowerCase()); return ((List<String>) TFM_ConfigEntry.HOST_SENDER_NAMES.getStringList()).contains(sender_name.toLowerCase());
} }
public static List<String> removeDuplicates(List<String> old_list) public static List<String> removeDuplicates(List<String> old_list)