forked from LogBlock/LogBlock
Changed to fixed MemorySection list methods
This commit is contained in:
@@ -2,8 +2,6 @@ package de.diddiz.LogBlock;
|
|||||||
|
|
||||||
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 de.diddiz.util.Utils.toIntList;
|
|
||||||
import static de.diddiz.util.Utils.toStringList;
|
|
||||||
import static org.bukkit.Bukkit.getConsoleSender;
|
import static org.bukkit.Bukkit.getConsoleSender;
|
||||||
import static org.bukkit.Bukkit.getLogger;
|
import static org.bukkit.Bukkit.getLogger;
|
||||||
import static org.bukkit.Bukkit.getWorlds;
|
import static org.bukkit.Bukkit.getWorlds;
|
||||||
@@ -119,7 +117,7 @@ public class Config extends LoggingEnabledMapping
|
|||||||
timePerRun = config.getInt("consumer.timePerRun", 100);
|
timePerRun = config.getInt("consumer.timePerRun", 100);
|
||||||
useBukkitScheduler = config.getBoolean("consumer.useBukkitScheduler", true);
|
useBukkitScheduler = config.getBoolean("consumer.useBukkitScheduler", true);
|
||||||
enableAutoClearLog = config.getBoolean("clearlog.enableAutoClearLog");
|
enableAutoClearLog = config.getBoolean("clearlog.enableAutoClearLog");
|
||||||
autoClearLog = toStringList(config.getList("clearlog.auto"));
|
autoClearLog = config.getStringList("clearlog.auto");
|
||||||
dumpDeletedLog = config.getBoolean("clearlog.dumpDeletedLog", false);
|
dumpDeletedLog = config.getBoolean("clearlog.dumpDeletedLog", false);
|
||||||
logCreeperExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
logCreeperExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
||||||
logPlayerInfo = config.getBoolean("logging.logPlayerInfo", true);
|
logPlayerInfo = config.getBoolean("logging.logPlayerInfo", true);
|
||||||
@@ -139,8 +137,8 @@ public class Config extends LoggingEnabledMapping
|
|||||||
else
|
else
|
||||||
throw new DataFormatException("Not a valid material: '" + blocktype + "'");
|
throw new DataFormatException("Not a valid material: '" + blocktype + "'");
|
||||||
}
|
}
|
||||||
dontRollback = new HashSet<Integer>(toIntList(config.getList("rollback.dontRollback")));
|
dontRollback = new HashSet<Integer>(config.getIntegerList("rollback.dontRollback"));
|
||||||
replaceAnyway = new HashSet<Integer>(toIntList(config.getList("rollback.replaceAnyway")));
|
replaceAnyway = new HashSet<Integer>(config.getIntegerList("rollback.replaceAnyway"));
|
||||||
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);
|
||||||
@@ -159,7 +157,7 @@ public class Config extends LoggingEnabledMapping
|
|||||||
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 = toStringList(tSec.getList("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);
|
||||||
@@ -181,7 +179,7 @@ public class Config extends LoggingEnabledMapping
|
|||||||
for (final String alias : tool.aliases)
|
for (final String alias : tool.aliases)
|
||||||
toolsByName.put(alias, tool);
|
toolsByName.put(alias, tool);
|
||||||
}
|
}
|
||||||
final List<String> loggedWorlds = toStringList(config.getList("loggedWorlds"));
|
final List<String> loggedWorlds = config.getStringList("loggedWorlds");
|
||||||
worlds = new HashMap<Integer, WorldConfig>();
|
worlds = new HashMap<Integer, WorldConfig>();
|
||||||
if (loggedWorlds.size() == 0)
|
if (loggedWorlds.size() == 0)
|
||||||
throw new DataFormatException("No worlds configured");
|
throw new DataFormatException("No worlds configured");
|
||||||
|
@@ -2,7 +2,6 @@ package de.diddiz.LogBlock;
|
|||||||
|
|
||||||
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
||||||
import static de.diddiz.util.Utils.readURL;
|
import static de.diddiz.util.Utils.readURL;
|
||||||
import static de.diddiz.util.Utils.toStringList;
|
|
||||||
import static org.bukkit.Bukkit.getLogger;
|
import static org.bukkit.Bukkit.getLogger;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -89,7 +88,7 @@ class Updater
|
|||||||
}
|
}
|
||||||
if (config.getString("version").compareTo("1.42") < 0) {
|
if (config.getString("version").compareTo("1.42") < 0) {
|
||||||
getLogger().info("[LogBlock] Updating config to 1.42 ...");
|
getLogger().info("[LogBlock] Updating config to 1.42 ...");
|
||||||
for (final String world : toStringList(config.getList("loggedWorlds"))) {
|
for (final String world : config.getStringList("loggedWorlds")) {
|
||||||
final File file = new File(logblock.getDataFolder(), friendlyWorldname(world) + ".yml");
|
final File file = new File(logblock.getDataFolder(), friendlyWorldname(world) + ".yml");
|
||||||
final YamlConfiguration wcfg = YamlConfiguration.loadConfiguration(file);
|
final YamlConfiguration wcfg = YamlConfiguration.loadConfiguration(file);
|
||||||
wcfg.set("logging.BLOCKPLACE", wcfg.getBoolean("logBlockCreations"));
|
wcfg.set("logging.BLOCKPLACE", wcfg.getBoolean("logBlockCreations"));
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package de.diddiz.util;
|
package de.diddiz.util;
|
||||||
|
|
||||||
import static org.bukkit.Bukkit.getLogger;
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -13,7 +12,6 @@ import java.io.OutputStream;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -182,32 +180,4 @@ public class Utils
|
|||||||
return name.toLowerCase().endsWith(ext);
|
return name.toLowerCase().endsWith(ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> toStringList(List<?> list) {
|
|
||||||
if (list == null)
|
|
||||||
return new ArrayList<String>();
|
|
||||||
final List<String> strs = new ArrayList<String>(list.size());
|
|
||||||
for (final Object obj : list)
|
|
||||||
if (obj instanceof String)
|
|
||||||
strs.add((String)obj);
|
|
||||||
else
|
|
||||||
strs.add(String.valueOf(obj));
|
|
||||||
return strs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Integer> toIntList(List<?> list) {
|
|
||||||
if (list == null)
|
|
||||||
return new ArrayList<Integer>();
|
|
||||||
final List<Integer> ints = new ArrayList<Integer>(list.size());
|
|
||||||
for (final Object obj : list)
|
|
||||||
if (obj instanceof Integer)
|
|
||||||
ints.add((Integer)obj);
|
|
||||||
else
|
|
||||||
try {
|
|
||||||
ints.add(Integer.valueOf(String.valueOf(obj)));
|
|
||||||
} catch (final NumberFormatException ex) {
|
|
||||||
getLogger().warning("[LogBlock] Config error: '" + obj + "' is not a number");
|
|
||||||
}
|
|
||||||
return ints;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user