TFM-4.3-Reloaded/src/main/java/me/StevenLawson/TotalFreedomMod/ban/PermbanList.java
2022-03-31 03:16:40 +01:00

56 lines
1.5 KiB
Java

package me.StevenLawson.TotalFreedomMod.ban;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.config.Configuration;
public class PermbanList {
private static final List<String> PERMBANNED_PLAYERS;
private static final List<String> PERMBANNED_IPS;
static {
PERMBANNED_PLAYERS = new ArrayList<String>();
PERMBANNED_IPS = new ArrayList<String>();
}
private PermbanList() {
throw new AssertionError();
}
public static List<String> getPermbannedPlayers() {
return Collections.unmodifiableList(PERMBANNED_PLAYERS);
}
public static List<String> getPermbannedIps() {
return Collections.unmodifiableList(PERMBANNED_IPS);
}
public static void load() {
PERMBANNED_PLAYERS.clear();
PERMBANNED_IPS.clear();
final Configuration config = new Configuration(TotalFreedomMod.plugin,
TotalFreedomMod.PERMBAN_FILENAME, true);
config.load();
for (String playername : config.getKeys(false)) {
PERMBANNED_PLAYERS.add(playername.toLowerCase().trim());
List<String> playerIps = config.getStringList(playername);
for (String ip : playerIps) {
ip = ip.trim();
if (!PERMBANNED_IPS.contains(ip)) {
PERMBANNED_IPS.add(ip);
}
}
}
Log.info("Loaded " + PERMBANNED_PLAYERS.size() + " permanently banned players and "
+ PERMBANNED_IPS.size() + " permanently banned IPs.");
}
}