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.BUILDNUM=479
program.BUILDDATE=08/23/2013 09\:18 PM
program.BUILDNUM=481
program.BUILDDATE=08/24/2013 09\:25 PM

View File

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

View File

@ -124,6 +124,37 @@ host_sender_names:
- rcon
- 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_enabled: false
twitterbot_url: ''

View File

@ -33,7 +33,7 @@ public class TFM_CommandBlocker
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)
{
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
{

View File

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

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
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)
{
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);
if (expire_date != null)
{
@ -110,7 +127,6 @@ public class TFM_ServerInterface
return ipBans.getEntries().containsKey(ip);
}
@SuppressWarnings("rawtypes")
public static int purgeWhitelist()
{
Set whitelisted = MinecraftServer.getServer().getPlayerList().getWhitelisted();
@ -181,7 +197,6 @@ public class TFM_ServerInterface
boolean is_ip_banned = false;
@SuppressWarnings("rawtypes")
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
while (ip_bans.hasNext())
{

View File

@ -746,7 +746,7 @@ public class TFM_Util
@SuppressWarnings("unchecked")
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)