forked from LogBlock/LogBlock
Update default config
This commit is contained in:
@ -1,27 +1,27 @@
|
|||||||
package de.diddiz.LogBlock;
|
package de.diddiz.LogBlock;
|
||||||
|
|
||||||
public enum Logging {
|
public enum Logging {
|
||||||
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true),
|
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true),
|
||||||
GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION(true), FIRE(true), LEAVESDECAY,
|
GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION(true), FIRE(true), LEAVESDECAY,
|
||||||
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
||||||
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT,
|
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT,
|
||||||
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
|
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
|
||||||
NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
|
NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
|
||||||
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW,
|
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW,
|
||||||
WORLDEDIT, TNTMINECARTEXPLOSION(true), LOCKEDCHESTDECAY, ENDERCRYSTALEXPLOSION(true);
|
WORLDEDIT, TNTMINECARTEXPLOSION(true), ENDERCRYSTALEXPLOSION(true);
|
||||||
|
|
||||||
public static final int length = Logging.values().length;
|
public static final int length = Logging.values().length;
|
||||||
private final boolean defaultEnabled;
|
private final boolean defaultEnabled;
|
||||||
|
|
||||||
private Logging() {
|
private Logging() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Logging(boolean defaultEnabled) {
|
private Logging(boolean defaultEnabled) {
|
||||||
this.defaultEnabled = defaultEnabled;
|
this.defaultEnabled = defaultEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDefaultEnabled() {
|
public boolean isDefaultEnabled() {
|
||||||
return defaultEnabled;
|
return defaultEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,309 +1,309 @@
|
|||||||
package de.diddiz.LogBlock.config;
|
package de.diddiz.LogBlock.config;
|
||||||
|
|
||||||
import de.diddiz.LogBlock.*;
|
import de.diddiz.LogBlock.*;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.zip.DataFormatException;
|
import java.util.zip.DataFormatException;
|
||||||
|
|
||||||
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
||||||
import static de.diddiz.util.Utils.parseTimeSpec;
|
import static de.diddiz.util.Utils.parseTimeSpec;
|
||||||
import static org.bukkit.Bukkit.*;
|
import static org.bukkit.Bukkit.*;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static LoggingEnabledMapping superWorldConfig;
|
private static LoggingEnabledMapping superWorldConfig;
|
||||||
private static Map<String, WorldConfig> worldConfigs;
|
private static Map<String, WorldConfig> worldConfigs;
|
||||||
public static String url, user, password;
|
public static String url, user, password;
|
||||||
public static int delayBetweenRuns, forceToProcessAtLeast, timePerRun;
|
public static int delayBetweenRuns, forceToProcessAtLeast, timePerRun;
|
||||||
public static boolean fireCustomEvents;
|
public static boolean fireCustomEvents;
|
||||||
public static boolean useBukkitScheduler;
|
public static boolean useBukkitScheduler;
|
||||||
public static int queueWarningSize;
|
public static int queueWarningSize;
|
||||||
public static boolean enableAutoClearLog;
|
public static boolean enableAutoClearLog;
|
||||||
public static List<String> autoClearLog;
|
public static List<String> autoClearLog;
|
||||||
public static int autoClearLogDelay;
|
public static int autoClearLogDelay;
|
||||||
public static boolean dumpDeletedLog;
|
public static boolean dumpDeletedLog;
|
||||||
public static boolean logCreeperExplosionsAsPlayerWhoTriggeredThese, logPlayerInfo;
|
public static boolean logCreeperExplosionsAsPlayerWhoTriggeredThese, logPlayerInfo;
|
||||||
public static LogKillsLevel logKillsLevel;
|
public static LogKillsLevel logKillsLevel;
|
||||||
public static Set<Material> dontRollback, replaceAnyway;
|
public static Set<Material> dontRollback, replaceAnyway;
|
||||||
public static int rollbackMaxTime, rollbackMaxArea;
|
public static int rollbackMaxTime, rollbackMaxArea;
|
||||||
public static Map<String, Tool> toolsByName;
|
public static Map<String, Tool> toolsByName;
|
||||||
public static Map<Material, Tool> toolsByType;
|
public static Map<Material, Tool> toolsByType;
|
||||||
public static int defaultDist, defaultTime;
|
public static int defaultDist, defaultTime;
|
||||||
public static int linesPerPage, linesLimit;
|
public static int linesPerPage, linesLimit;
|
||||||
public static boolean askRollbacks, askRedos, askClearLogs, askClearLogAfterRollback, askRollbackAfterBan;
|
public static boolean askRollbacks, askRedos, askClearLogs, askClearLogAfterRollback, askRollbackAfterBan;
|
||||||
public static String banPermission;
|
public static String banPermission;
|
||||||
public static Set<Material> hiddenBlocks;
|
public static Set<Material> hiddenBlocks;
|
||||||
public static Set<String> hiddenPlayers;
|
public static Set<String> hiddenPlayers;
|
||||||
public static Set<String> ignoredChat;
|
public static Set<String> ignoredChat;
|
||||||
public static SimpleDateFormat formatter;
|
public static SimpleDateFormat formatter;
|
||||||
public static boolean safetyIdCheck;
|
public static boolean safetyIdCheck;
|
||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
public static boolean logEnvironmentalKills;
|
public static boolean logEnvironmentalKills;
|
||||||
// Not loaded from config - checked at runtime
|
// Not loaded from config - checked at runtime
|
||||||
public static boolean mb4 = false;
|
public static boolean mb4 = false;
|
||||||
|
|
||||||
public static enum LogKillsLevel {
|
public static enum LogKillsLevel {
|
||||||
PLAYERS, MONSTERS, ANIMALS;
|
PLAYERS, MONSTERS, ANIMALS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(LogBlock logblock) throws DataFormatException, IOException {
|
public static void load(LogBlock logblock) throws DataFormatException, IOException {
|
||||||
final ConfigurationSection config = logblock.getConfig();
|
final ConfigurationSection config = logblock.getConfig();
|
||||||
final Map<String, Object> def = new HashMap<String, Object>();
|
final Map<String, Object> def = new HashMap<String, Object>();
|
||||||
def.put("version", logblock.getDescription().getVersion());
|
def.put("version", logblock.getDescription().getVersion());
|
||||||
final List<String> worldNames = new ArrayList<String>();
|
final List<String> worldNames = new ArrayList<String>();
|
||||||
for (final World world : getWorlds()) {
|
for (final World world : getWorlds()) {
|
||||||
worldNames.add(world.getName());
|
worldNames.add(world.getName());
|
||||||
}
|
}
|
||||||
if (worldNames.isEmpty()) {
|
if (worldNames.isEmpty()) {
|
||||||
worldNames.add("world");
|
worldNames.add("world");
|
||||||
worldNames.add("world_nether");
|
worldNames.add("world_nether");
|
||||||
worldNames.add("world_the_end");
|
worldNames.add("world_the_end");
|
||||||
}
|
}
|
||||||
def.put("loggedWorlds", worldNames);
|
def.put("loggedWorlds", worldNames);
|
||||||
def.put("mysql.host", "localhost");
|
def.put("mysql.host", "localhost");
|
||||||
def.put("mysql.port", 3306);
|
def.put("mysql.port", 3306);
|
||||||
def.put("mysql.database", "minecraft");
|
def.put("mysql.database", "minecraft");
|
||||||
def.put("mysql.user", "username");
|
def.put("mysql.user", "username");
|
||||||
def.put("mysql.password", "pass");
|
def.put("mysql.password", "pass");
|
||||||
def.put("consumer.delayBetweenRuns", 2);
|
def.put("consumer.delayBetweenRuns", 2);
|
||||||
def.put("consumer.forceToProcessAtLeast", 200);
|
def.put("consumer.forceToProcessAtLeast", 200);
|
||||||
def.put("consumer.timePerRun", 1000);
|
def.put("consumer.timePerRun", 1000);
|
||||||
def.put("consumer.fireCustomEvents", false);
|
def.put("consumer.fireCustomEvents", false);
|
||||||
def.put("consumer.useBukkitScheduler", true);
|
def.put("consumer.useBukkitScheduler", true);
|
||||||
def.put("consumer.queueWarningSize", 1000);
|
def.put("consumer.queueWarningSize", 1000);
|
||||||
def.put("clearlog.dumpDeletedLog", false);
|
def.put("clearlog.dumpDeletedLog", false);
|
||||||
def.put("clearlog.enableAutoClearLog", false);
|
def.put("clearlog.enableAutoClearLog", false);
|
||||||
def.put("clearlog.auto", Arrays.asList("world \"world\" before 365 days all", "world \"world\" player lavaflow waterflow leavesdecay before 7 days all", "world world_nether before 365 days all", "world world_nether player lavaflow before 7 days all"));
|
def.put("clearlog.auto", Arrays.asList("world \"world\" before 365 days all", "world \"world\" player lavaflow waterflow leavesdecay before 7 days all", "world world_nether before 365 days all", "world world_nether player lavaflow before 7 days all"));
|
||||||
def.put("clearlog.autoClearLogDelay", "6h");
|
def.put("clearlog.autoClearLogDelay", "6h");
|
||||||
def.put("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
def.put("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
||||||
def.put("logging.logKillsLevel", "PLAYERS");
|
def.put("logging.logKillsLevel", "PLAYERS");
|
||||||
def.put("logging.logEnvironmentalKills", false);
|
def.put("logging.logEnvironmentalKills", false);
|
||||||
def.put("logging.logPlayerInfo", false);
|
def.put("logging.logPlayerInfo", false);
|
||||||
def.put("logging.hiddenPlayers", new ArrayList<String>());
|
def.put("logging.hiddenPlayers", new ArrayList<String>());
|
||||||
def.put("logging.hiddenBlocks", Arrays.asList(0));
|
def.put("logging.hiddenBlocks", Arrays.asList(Material.AIR.name()));
|
||||||
def.put("logging.ignoredChat", Arrays.asList("/register", "/login"));
|
def.put("logging.ignoredChat", Arrays.asList("/register", "/login"));
|
||||||
def.put("rollback.dontRollback", Arrays.asList(10, 11, 46, 51));
|
def.put("rollback.dontRollback", Arrays.asList(Material.LAVA.name(), Material.TNT.name(), Material.FIRE.name()));
|
||||||
def.put("rollback.replaceAnyway", Arrays.asList(8, 9, 10, 11, 51));
|
def.put("rollback.replaceAnyway", Arrays.asList(Material.LAVA.name(), Material.WATER.name(), Material.FIRE.name()));
|
||||||
def.put("rollback.maxTime", "2 days");
|
def.put("rollback.maxTime", "2 days");
|
||||||
def.put("rollback.maxArea", 50);
|
def.put("rollback.maxArea", 50);
|
||||||
def.put("lookup.defaultDist", 20);
|
def.put("lookup.defaultDist", 20);
|
||||||
def.put("lookup.defaultTime", "30 minutes");
|
def.put("lookup.defaultTime", "30 minutes");
|
||||||
def.put("lookup.linesPerPage", 15);
|
def.put("lookup.linesPerPage", 15);
|
||||||
def.put("lookup.linesLimit", 1500);
|
def.put("lookup.linesLimit", 1500);
|
||||||
try {
|
try {
|
||||||
formatter = new SimpleDateFormat(config.getString("lookup.dateFormat", "MM-dd HH:mm:ss"));
|
formatter = new SimpleDateFormat(config.getString("lookup.dateFormat", "MM-dd HH:mm:ss"));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new DataFormatException("Invalid specification for date format, please see http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html : " + e.getMessage());
|
throw new DataFormatException("Invalid specification for date format, please see http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html : " + e.getMessage());
|
||||||
}
|
}
|
||||||
def.put("lookup.dateFormat", "MM-dd HH:mm:ss");
|
def.put("lookup.dateFormat", "MM-dd HH:mm:ss");
|
||||||
def.put("questioner.askRollbacks", true);
|
def.put("questioner.askRollbacks", true);
|
||||||
def.put("questioner.askRedos", true);
|
def.put("questioner.askRedos", true);
|
||||||
def.put("questioner.askClearLogs", true);
|
def.put("questioner.askClearLogs", true);
|
||||||
def.put("questioner.askClearLogAfterRollback", true);
|
def.put("questioner.askClearLogAfterRollback", true);
|
||||||
def.put("questioner.askRollbackAfterBan", false);
|
def.put("questioner.askRollbackAfterBan", false);
|
||||||
def.put("questioner.banPermission", "mcbans.ban.local");
|
def.put("questioner.banPermission", "mcbans.ban.local");
|
||||||
def.put("tools.tool.aliases", Arrays.asList("t"));
|
def.put("tools.tool.aliases", Arrays.asList("t"));
|
||||||
def.put("tools.tool.leftClickBehavior", "NONE");
|
def.put("tools.tool.leftClickBehavior", "NONE");
|
||||||
def.put("tools.tool.rightClickBehavior", "TOOL");
|
def.put("tools.tool.rightClickBehavior", "TOOL");
|
||||||
def.put("tools.tool.defaultEnabled", true);
|
def.put("tools.tool.defaultEnabled", true);
|
||||||
def.put("tools.tool.item", 270);
|
def.put("tools.tool.item", Material.WOODEN_PICKAXE.name());
|
||||||
def.put("tools.tool.canDrop", true);
|
def.put("tools.tool.canDrop", true);
|
||||||
def.put("tools.tool.params", "area 0 all sum none limit 15 desc silent");
|
def.put("tools.tool.params", "area 0 all sum none limit 15 desc silent");
|
||||||
def.put("tools.tool.mode", "LOOKUP");
|
def.put("tools.tool.mode", "LOOKUP");
|
||||||
def.put("tools.tool.permissionDefault", "OP");
|
def.put("tools.tool.permissionDefault", "OP");
|
||||||
def.put("tools.toolblock.aliases", Arrays.asList("tb"));
|
def.put("tools.toolblock.aliases", Arrays.asList("tb"));
|
||||||
def.put("tools.toolblock.leftClickBehavior", "TOOL");
|
def.put("tools.toolblock.leftClickBehavior", "TOOL");
|
||||||
def.put("tools.toolblock.rightClickBehavior", "BLOCK");
|
def.put("tools.toolblock.rightClickBehavior", "BLOCK");
|
||||||
def.put("tools.toolblock.defaultEnabled", true);
|
def.put("tools.toolblock.defaultEnabled", true);
|
||||||
def.put("tools.toolblock.item", 7);
|
def.put("tools.toolblock.item", Material.BEDROCK.name());
|
||||||
def.put("tools.toolblock.canDrop", false);
|
def.put("tools.toolblock.canDrop", false);
|
||||||
def.put("tools.toolblock.params", "area 0 all sum none limit 15 desc silent");
|
def.put("tools.toolblock.params", "area 0 all sum none limit 15 desc silent");
|
||||||
def.put("tools.toolblock.mode", "LOOKUP");
|
def.put("tools.toolblock.mode", "LOOKUP");
|
||||||
def.put("tools.toolblock.permissionDefault", "OP");
|
def.put("tools.toolblock.permissionDefault", "OP");
|
||||||
def.put("safety.id.check", true);
|
def.put("safety.id.check", true);
|
||||||
def.put("debug", false);
|
def.put("debug", false);
|
||||||
for (final Entry<String, Object> e : def.entrySet()) {
|
for (final Entry<String, Object> e : def.entrySet()) {
|
||||||
if (!config.contains(e.getKey())) {
|
if (!config.contains(e.getKey())) {
|
||||||
config.set(e.getKey(), e.getValue());
|
config.set(e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logblock.saveConfig();
|
logblock.saveConfig();
|
||||||
url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port") + "/" + getStringIncludingInts(config, "mysql.database");
|
url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port") + "/" + getStringIncludingInts(config, "mysql.database");
|
||||||
user = getStringIncludingInts(config, "mysql.user");
|
user = getStringIncludingInts(config, "mysql.user");
|
||||||
password = getStringIncludingInts(config, "mysql.password");
|
password = getStringIncludingInts(config, "mysql.password");
|
||||||
delayBetweenRuns = config.getInt("consumer.delayBetweenRuns", 2);
|
delayBetweenRuns = config.getInt("consumer.delayBetweenRuns", 2);
|
||||||
forceToProcessAtLeast = config.getInt("consumer.forceToProcessAtLeast", 0);
|
forceToProcessAtLeast = config.getInt("consumer.forceToProcessAtLeast", 0);
|
||||||
timePerRun = config.getInt("consumer.timePerRun", 1000);
|
timePerRun = config.getInt("consumer.timePerRun", 1000);
|
||||||
fireCustomEvents = config.getBoolean("consumer.fireCustomEvents", false);
|
fireCustomEvents = config.getBoolean("consumer.fireCustomEvents", false);
|
||||||
useBukkitScheduler = config.getBoolean("consumer.useBukkitScheduler", true);
|
useBukkitScheduler = config.getBoolean("consumer.useBukkitScheduler", true);
|
||||||
queueWarningSize = config.getInt("consumer.queueWarningSize", 1000);
|
queueWarningSize = config.getInt("consumer.queueWarningSize", 1000);
|
||||||
enableAutoClearLog = config.getBoolean("clearlog.enableAutoClearLog");
|
enableAutoClearLog = config.getBoolean("clearlog.enableAutoClearLog");
|
||||||
autoClearLog = config.getStringList("clearlog.auto");
|
autoClearLog = config.getStringList("clearlog.auto");
|
||||||
dumpDeletedLog = config.getBoolean("clearlog.dumpDeletedLog", false);
|
dumpDeletedLog = config.getBoolean("clearlog.dumpDeletedLog", false);
|
||||||
autoClearLogDelay = parseTimeSpec(config.getString("clearlog.autoClearLogDelay").split(" "));
|
autoClearLogDelay = parseTimeSpec(config.getString("clearlog.autoClearLogDelay").split(" "));
|
||||||
logCreeperExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
logCreeperExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
||||||
logPlayerInfo = config.getBoolean("logging.logPlayerInfo", true);
|
logPlayerInfo = config.getBoolean("logging.logPlayerInfo", true);
|
||||||
try {
|
try {
|
||||||
logKillsLevel = LogKillsLevel.valueOf(config.getString("logging.logKillsLevel").toUpperCase());
|
logKillsLevel = LogKillsLevel.valueOf(config.getString("logging.logKillsLevel").toUpperCase());
|
||||||
} catch (final IllegalArgumentException ex) {
|
} catch (final IllegalArgumentException ex) {
|
||||||
throw new DataFormatException("logging.logKillsLevel doesn't appear to be a valid log level. Allowed are 'PLAYERS', 'MONSTERS' and 'ANIMALS'");
|
throw new DataFormatException("logging.logKillsLevel doesn't appear to be a valid log level. Allowed are 'PLAYERS', 'MONSTERS' and 'ANIMALS'");
|
||||||
}
|
}
|
||||||
logEnvironmentalKills = config.getBoolean("logging.logEnvironmentalKills", false);
|
logEnvironmentalKills = config.getBoolean("logging.logEnvironmentalKills", false);
|
||||||
hiddenPlayers = new HashSet<String>();
|
hiddenPlayers = new HashSet<String>();
|
||||||
for (final String playerName : config.getStringList("logging.hiddenPlayers")) {
|
for (final String playerName : config.getStringList("logging.hiddenPlayers")) {
|
||||||
hiddenPlayers.add(playerName.toLowerCase().trim());
|
hiddenPlayers.add(playerName.toLowerCase().trim());
|
||||||
}
|
}
|
||||||
hiddenBlocks = new HashSet<Material>();
|
hiddenBlocks = new HashSet<Material>();
|
||||||
for (final String blocktype : config.getStringList("logging.hiddenBlocks")) {
|
for (final String blocktype : config.getStringList("logging.hiddenBlocks")) {
|
||||||
final Material mat = Material.matchMaterial(blocktype);
|
final Material mat = Material.matchMaterial(blocktype);
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
hiddenBlocks.add(mat);
|
hiddenBlocks.add(mat);
|
||||||
} else {
|
} else {
|
||||||
throw new DataFormatException("Not a valid material in hiddenBlocks: '" + blocktype + "'");
|
throw new DataFormatException("Not a valid material in hiddenBlocks: '" + blocktype + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ignoredChat = new HashSet<String>();
|
ignoredChat = new HashSet<String>();
|
||||||
for (String chatCommand : config.getStringList("logging.ignoredChat")) {
|
for (String chatCommand : config.getStringList("logging.ignoredChat")) {
|
||||||
ignoredChat.add(chatCommand);
|
ignoredChat.add(chatCommand);
|
||||||
}
|
}
|
||||||
dontRollback = new HashSet<Material>();
|
dontRollback = new HashSet<Material>();
|
||||||
for (String e : config.getStringList("rollback.dontRollback")) {
|
for (String e : config.getStringList("rollback.dontRollback")) {
|
||||||
Material mat = Material.matchMaterial(e);
|
Material mat = Material.matchMaterial(e);
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
dontRollback.add(mat);
|
dontRollback.add(mat);
|
||||||
} else {
|
} else {
|
||||||
throw new DataFormatException("Not a valid material in dontRollback: '" + e + "'");
|
throw new DataFormatException("Not a valid material in dontRollback: '" + e + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
replaceAnyway = new HashSet<Material>();
|
replaceAnyway = new HashSet<Material>();
|
||||||
for (String e : config.getStringList("rollback.replaceAnyway")) {
|
for (String e : config.getStringList("rollback.replaceAnyway")) {
|
||||||
Material mat = Material.matchMaterial(e);
|
Material mat = Material.matchMaterial(e);
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
replaceAnyway.add(mat);
|
replaceAnyway.add(mat);
|
||||||
} else {
|
} else {
|
||||||
throw new DataFormatException("Not a valid material in replaceAnyway: '" + e + "'");
|
throw new DataFormatException("Not a valid material in replaceAnyway: '" + e + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rollbackMaxTime = parseTimeSpec(config.getString("rollback.maxTime").split(" "));
|
rollbackMaxTime = parseTimeSpec(config.getString("rollback.maxTime").split(" "));
|
||||||
rollbackMaxArea = config.getInt("rollback.maxArea", 50);
|
rollbackMaxArea = config.getInt("rollback.maxArea", 50);
|
||||||
defaultDist = config.getInt("lookup.defaultDist", 20);
|
defaultDist = config.getInt("lookup.defaultDist", 20);
|
||||||
defaultTime = parseTimeSpec(config.getString("lookup.defaultTime").split(" "));
|
defaultTime = parseTimeSpec(config.getString("lookup.defaultTime").split(" "));
|
||||||
linesPerPage = config.getInt("lookup.linesPerPage", 15);
|
linesPerPage = config.getInt("lookup.linesPerPage", 15);
|
||||||
linesLimit = config.getInt("lookup.linesLimit", 1500);
|
linesLimit = config.getInt("lookup.linesLimit", 1500);
|
||||||
askRollbacks = config.getBoolean("questioner.askRollbacks", true);
|
askRollbacks = config.getBoolean("questioner.askRollbacks", true);
|
||||||
askRedos = config.getBoolean("questioner.askRedos", true);
|
askRedos = config.getBoolean("questioner.askRedos", true);
|
||||||
askClearLogs = config.getBoolean("questioner.askClearLogs", true);
|
askClearLogs = config.getBoolean("questioner.askClearLogs", true);
|
||||||
askClearLogAfterRollback = config.getBoolean("questioner.askClearLogAfterRollback", true);
|
askClearLogAfterRollback = config.getBoolean("questioner.askClearLogAfterRollback", true);
|
||||||
askRollbackAfterBan = config.getBoolean("questioner.askRollbackAfterBan", false);
|
askRollbackAfterBan = config.getBoolean("questioner.askRollbackAfterBan", false);
|
||||||
safetyIdCheck = config.getBoolean("safety.id.check", true);
|
safetyIdCheck = config.getBoolean("safety.id.check", true);
|
||||||
debug = config.getBoolean("debug", false);
|
debug = config.getBoolean("debug", false);
|
||||||
banPermission = config.getString("questioner.banPermission");
|
banPermission = config.getString("questioner.banPermission");
|
||||||
final List<Tool> tools = new ArrayList<Tool>();
|
final List<Tool> tools = new ArrayList<Tool>();
|
||||||
final ConfigurationSection toolsSec = config.getConfigurationSection("tools");
|
final ConfigurationSection toolsSec = config.getConfigurationSection("tools");
|
||||||
for (final String toolName : toolsSec.getKeys(false)) {
|
for (final String toolName : toolsSec.getKeys(false)) {
|
||||||
try {
|
try {
|
||||||
final ConfigurationSection tSec = toolsSec.getConfigurationSection(toolName);
|
final ConfigurationSection tSec = toolsSec.getConfigurationSection(toolName);
|
||||||
final List<String> aliases = tSec.getStringList("aliases");
|
final List<String> aliases = tSec.getStringList("aliases");
|
||||||
final ToolBehavior leftClickBehavior = ToolBehavior.valueOf(tSec.getString("leftClickBehavior").toUpperCase());
|
final ToolBehavior leftClickBehavior = ToolBehavior.valueOf(tSec.getString("leftClickBehavior").toUpperCase());
|
||||||
final ToolBehavior rightClickBehavior = ToolBehavior.valueOf(tSec.getString("rightClickBehavior").toUpperCase());
|
final ToolBehavior rightClickBehavior = ToolBehavior.valueOf(tSec.getString("rightClickBehavior").toUpperCase());
|
||||||
final boolean defaultEnabled = tSec.getBoolean("defaultEnabled", false);
|
final boolean defaultEnabled = tSec.getBoolean("defaultEnabled", false);
|
||||||
final Material item = Material.matchMaterial(tSec.getString("item","OAK_LOG"));
|
final Material item = Material.matchMaterial(tSec.getString("item","OAK_LOG"));
|
||||||
final boolean canDrop = tSec.getBoolean("canDrop", false);
|
final boolean canDrop = tSec.getBoolean("canDrop", false);
|
||||||
final QueryParams params = new QueryParams(logblock);
|
final QueryParams params = new QueryParams(logblock);
|
||||||
params.prepareToolQuery = true;
|
params.prepareToolQuery = true;
|
||||||
params.parseArgs(getConsoleSender(), Arrays.asList(tSec.getString("params").split(" ")));
|
params.parseArgs(getConsoleSender(), Arrays.asList(tSec.getString("params").split(" ")));
|
||||||
final ToolMode mode = ToolMode.valueOf(tSec.getString("mode").toUpperCase());
|
final ToolMode mode = ToolMode.valueOf(tSec.getString("mode").toUpperCase());
|
||||||
final PermissionDefault pdef = PermissionDefault.valueOf(tSec.getString("permissionDefault").toUpperCase());
|
final PermissionDefault pdef = PermissionDefault.valueOf(tSec.getString("permissionDefault").toUpperCase());
|
||||||
tools.add(new Tool(toolName, aliases, leftClickBehavior, rightClickBehavior, defaultEnabled, item, canDrop, params, mode, pdef));
|
tools.add(new Tool(toolName, aliases, leftClickBehavior, rightClickBehavior, defaultEnabled, item, canDrop, params, mode, pdef));
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
getLogger().log(Level.WARNING, "Error at parsing tool '" + toolName + "': ", ex);
|
getLogger().log(Level.WARNING, "Error at parsing tool '" + toolName + "': ", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toolsByName = new HashMap<String, Tool>();
|
toolsByName = new HashMap<String, Tool>();
|
||||||
toolsByType = new HashMap<Material, Tool>();
|
toolsByType = new HashMap<Material, Tool>();
|
||||||
for (final Tool tool : tools) {
|
for (final Tool tool : tools) {
|
||||||
toolsByType.put(tool.item, tool);
|
toolsByType.put(tool.item, tool);
|
||||||
toolsByName.put(tool.name.toLowerCase(), tool);
|
toolsByName.put(tool.name.toLowerCase(), tool);
|
||||||
for (final String alias : tool.aliases) {
|
for (final String alias : tool.aliases) {
|
||||||
toolsByName.put(alias, tool);
|
toolsByName.put(alias, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final List<String> loggedWorlds = config.getStringList("loggedWorlds");
|
final List<String> loggedWorlds = config.getStringList("loggedWorlds");
|
||||||
worldConfigs = new HashMap<String, WorldConfig>();
|
worldConfigs = new HashMap<String, WorldConfig>();
|
||||||
if (loggedWorlds.isEmpty()) {
|
if (loggedWorlds.isEmpty()) {
|
||||||
throw new DataFormatException("No worlds configured");
|
throw new DataFormatException("No worlds configured");
|
||||||
}
|
}
|
||||||
for (final String world : loggedWorlds) {
|
for (final String world : loggedWorlds) {
|
||||||
worldConfigs.put(world, new WorldConfig(new File(logblock.getDataFolder(), friendlyWorldname(world) + ".yml")));
|
worldConfigs.put(world, new WorldConfig(new File(logblock.getDataFolder(), friendlyWorldname(world) + ".yml")));
|
||||||
}
|
}
|
||||||
superWorldConfig = new LoggingEnabledMapping();
|
superWorldConfig = new LoggingEnabledMapping();
|
||||||
for (final WorldConfig wcfg : worldConfigs.values()) {
|
for (final WorldConfig wcfg : worldConfigs.values()) {
|
||||||
for (final Logging l : Logging.values()) {
|
for (final Logging l : Logging.values()) {
|
||||||
if (wcfg.isLogging(l)) {
|
if (wcfg.isLogging(l)) {
|
||||||
superWorldConfig.setLogging(l, true);
|
superWorldConfig.setLogging(l, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||||
String str = cfg.getString(key);
|
String str = cfg.getString(key);
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
str = String.valueOf(cfg.getInt(key));
|
str = String.valueOf(cfg.getInt(key));
|
||||||
}
|
}
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
str = "No value set for '" + key + "'";
|
str = "No value set for '" + key + "'";
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLogging(World world, Logging l) {
|
public static boolean isLogging(World world, Logging l) {
|
||||||
final WorldConfig wcfg = worldConfigs.get(world.getName());
|
final WorldConfig wcfg = worldConfigs.get(world.getName());
|
||||||
return wcfg != null && wcfg.isLogging(l);
|
return wcfg != null && wcfg.isLogging(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLogging(String worldName, Logging l) {
|
public static boolean isLogging(String worldName, Logging l) {
|
||||||
final WorldConfig wcfg = worldConfigs.get(worldName);
|
final WorldConfig wcfg = worldConfigs.get(worldName);
|
||||||
return wcfg != null && wcfg.isLogging(l);
|
return wcfg != null && wcfg.isLogging(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLogged(World world) {
|
public static boolean isLogged(World world) {
|
||||||
return worldConfigs.containsKey(world.getName());
|
return worldConfigs.containsKey(world.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldConfig getWorldConfig(World world) {
|
public static WorldConfig getWorldConfig(World world) {
|
||||||
return worldConfigs.get(world.getName());
|
return worldConfigs.get(world.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldConfig getWorldConfig(String world) {
|
public static WorldConfig getWorldConfig(String world) {
|
||||||
return worldConfigs.get(world);
|
return worldConfigs.get(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLogging(Logging l) {
|
public static boolean isLogging(Logging l) {
|
||||||
return superWorldConfig.isLogging(l);
|
return superWorldConfig.isLogging(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<WorldConfig> getLoggedWorlds() {
|
public static Collection<WorldConfig> getLoggedWorlds() {
|
||||||
return worldConfigs.values();
|
return worldConfigs.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoggingEnabledMapping {
|
class LoggingEnabledMapping {
|
||||||
private final boolean[] logging = new boolean[Logging.length];
|
private final boolean[] logging = new boolean[Logging.length];
|
||||||
|
|
||||||
public void setLogging(Logging l, boolean enabled) {
|
public void setLogging(Logging l, boolean enabled) {
|
||||||
logging[l.ordinal()] = enabled;
|
logging[l.ordinal()] = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLogging(Logging l) {
|
public boolean isLogging(Logging l) {
|
||||||
return logging[l.ordinal()];
|
return logging[l.ordinal()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user