[Bleeding] Block listed IPs from being supered. Resolves #201

This commit is contained in:
JeromSar 2014-10-30 19:44:05 +01:00
parent af64a77268
commit 8b45482d0a
6 changed files with 19 additions and 7 deletions

View file

@ -233,6 +233,10 @@ unbannable_usernames:
- dantdm
- gizzy14gazza
# IPs that can not be supered
noadmin_ips:
- 127.0.0.1
# TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot:
enabled: false

View file

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
@ -134,7 +135,7 @@ public class Command_saconfig extends TFM_Command
return true;
}
player = me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, superadmin.getLastLoginName());
player = TFM_DepreciationAggregator.getOfflinePlayer(server, superadmin.getLastLoginName());
}
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list", true);
@ -171,7 +172,7 @@ public class Command_saconfig extends TFM_Command
}
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
TFM_AdminList.removeSuperadmin(me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator.getOfflinePlayer(server, targetName));
TFM_AdminList.removeSuperadmin(TFM_DepreciationAggregator.getOfflinePlayer(server, targetName));
// Twitterbot
if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
@ -194,7 +195,6 @@ public class Command_saconfig extends TFM_Command
INFO("info", AdminLevel.SUPER, SourceType.BOTH, 2, 2),
ADD("add", AdminLevel.SUPER, SourceType.ONLY_CONSOLE, 2, 2),
DELETE("delete", AdminLevel.SENIOR, SourceType.ONLY_CONSOLE, 2, 2);
private final String modeName;
private final AdminLevel adminLevel;
private final SourceType sourceType;

View file

@ -76,6 +76,7 @@ public enum TFM_ConfigEntry
BLOCKED_COMMANDS(List.class, "blocked_commands"),
HOST_SENDER_NAMES(List.class, "host_sender_names"),
UNBANNABLE_USERNAMES(List.class, "unbannable_usernames"),
NOADMIN_IPS(List.class, "noadmin_ips"),
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
CONSOLE_IS_SENIOR(Boolean.class, "console_is_senior");

View file

@ -11,9 +11,9 @@ import java.util.Map;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Method;
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Response;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import net.minecraft.util.org.apache.commons.lang3.StringEscapeUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
@ -27,8 +27,7 @@ public class Module_schematic extends TFM_HTTPD_Module
{
"schematic"
};
private static final String UPLOAD_FORM
= "<form method=\"post\" name=\"schematicForm\" id=\"schematicForm\" action=\"/schematic/upload/\" enctype=\"multipart/form-data\">\n"
private static final String UPLOAD_FORM = "<form method=\"post\" name=\"schematicForm\" id=\"schematicForm\" action=\"/schematic/upload/\" enctype=\"multipart/form-data\">\n"
+ "<p>Select a schematic file to upload. Filenames must be alphanumeric, between 1 and 30 characters long (inclusive), and have a .schematic extension.</p>\n"
+ "<input type=\"file\" id=\"schematicFile\" name=\"schematicFile\" />\n"
+ "<br />\n"

View file

@ -3,8 +3,11 @@ package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.Config.TFM_MainConfig;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.configuration.ConfigurationSection;
@ -44,6 +47,11 @@ public class TFM_Admin
this.isTelnetAdmin = section.getBoolean("is_telnet_admin", false);
this.consoleAliases = section.getStringList("console_aliases");
this.isActivated = section.getBoolean("is_activated", true);
for (Iterator<?> it = TFM_MainConfig.getList(TFM_ConfigEntry.NOADMIN_IPS).iterator(); it.hasNext();)
{
ips.remove((String) it.next());
}
}
@Override

View file

@ -566,7 +566,7 @@ public class TFM_AdminList
{
superadmin.setLastLogin(new Date());
if (ip != null)
if (ip != null && !TFM_MainConfig.getList(TFM_ConfigEntry.NOADMIN_IPS).contains(ip))
{
superadmin.addIp(ip);
}