forked from LogBlock/LogBlock
Fixes for changed configuration handling in CB 1317
This commit is contained in:
@@ -41,7 +41,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
CommandsHandler(LogBlock logblock) {
|
||||
this.logblock = logblock;
|
||||
log = logblock.getServer().getLogger();
|
||||
config = logblock.getConfig();
|
||||
config = logblock.getLBConfig();
|
||||
scheduler = logblock.getServer().getScheduler();
|
||||
questioner = (LogBlockQuestioner)logblock.getServer().getPluginManager().getPlugin("LogBlockQuestioner");
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
} else if (command.equals("rollback") || command.equals("undo") || command.equals("rb")) {
|
||||
if (logblock.hasPermission(sender, "logblock.rollback")) {
|
||||
final QueryParams params = new QueryParams(logblock);
|
||||
params.since = logblock.getConfig().defaultTime;
|
||||
params.since = config.defaultTime;
|
||||
params.bct = BlockChangeType.ALL;
|
||||
params.parseArgs(sender, argsToList(args, 1));
|
||||
new CommandRollback(sender, params, true);
|
||||
@@ -233,7 +233,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
} else if (command.equals("redo")) {
|
||||
if (logblock.hasPermission(sender, "logblock.rollback")) {
|
||||
final QueryParams params = new QueryParams(logblock);
|
||||
params.since = logblock.getConfig().defaultTime;
|
||||
params.since = config.defaultTime;
|
||||
params.bct = BlockChangeType.ALL;
|
||||
params.parseArgs(sender, argsToList(args, 1));
|
||||
new CommandRedo(sender, params, true);
|
||||
|
@@ -16,8 +16,9 @@ import java.util.logging.Level;
|
||||
import java.util.zip.DataFormatException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class Config
|
||||
{
|
||||
@@ -32,8 +33,8 @@ public class Config
|
||||
public final LogKillsLevel logKillsLevel;
|
||||
public final Set<Integer> dontRollback, replaceAnyway;
|
||||
public final int rollbackMaxTime, rollbackMaxArea;
|
||||
public final HashMap<String, Tool> toolsByName;
|
||||
public final HashMap<Integer, Tool> toolsByType;
|
||||
public final Map<String, Tool> toolsByName;
|
||||
public final Map<Integer, Tool> toolsByType;
|
||||
public final int defaultDist, defaultTime;
|
||||
public final int linesPerPage, linesLimit;
|
||||
public final boolean askRollbacks, askRedos, askClearLogs, askClearLogAfterRollback, askRollbackAfterBan;
|
||||
@@ -42,11 +43,12 @@ public class Config
|
||||
public final Set<Integer> hiddenPlayers, hiddenBlocks;
|
||||
|
||||
public static enum LogKillsLevel {
|
||||
PLAYERS, MONSTERS, ANIMALS
|
||||
PLAYERS, MONSTERS, ANIMALS;
|
||||
}
|
||||
|
||||
Config(LogBlock logblock) throws DataFormatException, IOException {
|
||||
final Map<String, Object> def = new HashMap<String, Object>(), tooldef = new HashMap<String, Object>(), tbdef = new HashMap<String, Object>(), tdef = new HashMap<String, Object>();
|
||||
final FileConfiguration config = logblock.getConfig();
|
||||
final Map<String, Object> def = new HashMap<String, Object>();
|
||||
def.put("version", logblock.getDescription().getVersion());
|
||||
def.put("loggedWorlds", Arrays.asList("world", "world_nether"));
|
||||
def.put("mysql.host", "localhost");
|
||||
@@ -81,32 +83,26 @@ public class Config
|
||||
def.put("questioner.banPermission", "mcbans.ban.local");
|
||||
def.put("updater.installSpout", true);
|
||||
def.put("updater.checkVersion", true);
|
||||
tdef.put("aliases", Arrays.asList("t"));
|
||||
tdef.put("leftClickBehavior", "NONE");
|
||||
tdef.put("rightClickBehavior", "TOOL");
|
||||
tdef.put("defaultEnabled", true);
|
||||
tdef.put("item", 270);
|
||||
tdef.put("params", "area 0 all sum none limit 15 desc silent");
|
||||
tdef.put("mode", "LOOKUP");
|
||||
tdef.put("permissionDefault", "TRUE");
|
||||
tbdef.put("aliases", Arrays.asList("tb"));
|
||||
tbdef.put("leftClickBehavior", "TOOL");
|
||||
tbdef.put("rightClickBehavior", "BLOCK");
|
||||
tbdef.put("defaultEnabled", true);
|
||||
tbdef.put("item", 7);
|
||||
tbdef.put("params", "area 0 all sum none limit 15 desc silent");
|
||||
tbdef.put("mode", "LOOKUP");
|
||||
tbdef.put("permissionDefault", "TRUE");
|
||||
tooldef.put("tool", tdef);
|
||||
tooldef.put("toolblock", tbdef);
|
||||
def.put("tools", tooldef);
|
||||
final Configuration config = logblock.getConfiguration();
|
||||
config.load();
|
||||
def.put("tools.tool.aliases", Arrays.asList("t"));
|
||||
def.put("tools.tool.leftClickBehavior", "NONE");
|
||||
def.put("tools.tool.rightClickBehavior", "TOOL");
|
||||
def.put("tools.tool.defaultEnabled", true);
|
||||
def.put("tools.tool.item", 270);
|
||||
def.put("tools.tool.params", "area 0 all sum none limit 15 desc silent");
|
||||
def.put("tools.tool.mode", "LOOKUP");
|
||||
def.put("tools.tool.permissionDefault", "TRUE");
|
||||
def.put("tools.toolblock.aliases", Arrays.asList("tb"));
|
||||
def.put("tools.toolblock.leftClickBehavior", "TOOL");
|
||||
def.put("tools.toolblock.rightClickBehavior", "BLOCK");
|
||||
def.put("tools.toolblock.defaultEnabled", true);
|
||||
def.put("tools.toolblock.item", 7);
|
||||
def.put("tools.toolblock.params", "area 0 all sum none limit 15 desc silent");
|
||||
def.put("tools.toolblock.mode", "LOOKUP");
|
||||
def.put("tools.toolblock.permissionDefault", "TRUE");
|
||||
for (final Entry<String, Object> e : def.entrySet())
|
||||
if (config.getProperty(e.getKey()) == null)
|
||||
config.setProperty(e.getKey(), e.getValue());
|
||||
if (!config.save())
|
||||
throw new IOException("Error while writing to config.yml");
|
||||
if (!config.contains(e.getKey()))
|
||||
config.set(e.getKey(), e.getValue());
|
||||
logblock.saveConfig();
|
||||
url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getString("mysql.port") + "/" + config.getString("mysql.database");
|
||||
user = config.getString("mysql.user");
|
||||
password = config.getString("mysql.password");
|
||||
@@ -126,18 +122,18 @@ public class Config
|
||||
throw new DataFormatException("lookup.toolblockID doesn't appear to be a valid log level. Allowed are 'PLAYERS', 'MONSTERS' and 'ANIMALS'");
|
||||
}
|
||||
hiddenPlayers = new HashSet<Integer>();
|
||||
for (final String playerName : config.getStringList("logging.hiddenPlayers", new ArrayList<String>()))
|
||||
for (final Object playerName : config.getList("logging.hiddenPlayers"))
|
||||
hiddenPlayers.add(playerName.hashCode());
|
||||
hiddenBlocks = new HashSet<Integer>();
|
||||
for (final String blocktype : config.getStringList("logging.hiddenBlocks", new ArrayList<String>())) {
|
||||
final Material mat = Material.matchMaterial(blocktype);
|
||||
for (final Object blocktype : config.getList("logging.hiddenBlocks")) {
|
||||
final Material mat = Material.matchMaterial(String.valueOf(blocktype));
|
||||
if (mat != null)
|
||||
hiddenBlocks.add(mat.getId());
|
||||
else
|
||||
throw new DataFormatException("Not a valid material: '" + blocktype + "'");
|
||||
}
|
||||
dontRollback = new HashSet<Integer>(config.getIntList("rollback.dontRollback", null));
|
||||
replaceAnyway = new HashSet<Integer>(config.getIntList("rollback.replaceAnyway", null));
|
||||
dontRollback = new HashSet<Integer>(toIntList(config.getList("rollback.dontRollback")));
|
||||
replaceAnyway = new HashSet<Integer>(toIntList(config.getList("rollback.replaceAnyway")));
|
||||
rollbackMaxTime = parseTimeSpec(config.getString("rollback.maxTime").split(" "));
|
||||
rollbackMaxArea = config.getInt("rollback.maxArea", 50);
|
||||
defaultDist = config.getInt("lookup.defaultDist", 20);
|
||||
@@ -152,12 +148,11 @@ public class Config
|
||||
banPermission = config.getString("questioner.banPermission");
|
||||
installSpout = config.getBoolean("updater.installSpout", true);
|
||||
checkVersion = config.getBoolean("updater.checkVersion", true);
|
||||
final List<String> toolNames = config.getKeys("tools");
|
||||
final List<Tool> tools = new ArrayList<Tool>();
|
||||
for (final String toolName : toolNames)
|
||||
for (final String toolName : config.getConfigurationSection("tools").getKeys(false))
|
||||
try {
|
||||
final String path = "tools." + toolName;
|
||||
final List<String> aliases = config.getStringList(path + ".aliases", null);
|
||||
final List<String> aliases = toStringList(config.getList(path + ".aliases"));
|
||||
final ToolBehavior leftClickBehavior = ToolBehavior.valueOf(config.getString(path + ".leftClickBehavior").toUpperCase());
|
||||
final ToolBehavior rightClickBehavior = ToolBehavior.valueOf(config.getString(path + ".rightClickBehavior").toUpperCase());
|
||||
final boolean defaultEnabled = config.getBoolean(path + ".defaultEnabled", false);
|
||||
@@ -179,9 +174,9 @@ public class Config
|
||||
for (final String alias : tool.aliases)
|
||||
toolsByName.put(alias, tool);
|
||||
}
|
||||
final List<String> worldNames = config.getStringList("loggedWorlds", null);
|
||||
final List<String> worldNames = toStringList(config.getList("loggedWorlds"));
|
||||
worlds = new HashMap<Integer, WorldConfig>();
|
||||
if (worldNames == null || worldNames.size() == 0)
|
||||
if (worldNames.size() == 0)
|
||||
throw new DataFormatException("No worlds configured");
|
||||
for (final String world : worldNames)
|
||||
worlds.put(world.hashCode(), new WorldConfig(new File("plugins/LogBlock/" + friendlyWorldname(world) + ".yml")));
|
||||
@@ -222,6 +217,34 @@ public class Config
|
||||
logEndermen = true;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
Bukkit.getLogger().warning("[LogBlock] Config error: '" + obj + "' is not a number");
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
}
|
||||
|
||||
class WorldConfig
|
||||
@@ -229,7 +252,7 @@ class WorldConfig
|
||||
public final String table;
|
||||
public final boolean logBlockPlacings, logBlockBreaks, logSignTexts, logExplosions, logFire, logLeavesDecay, logLavaFlow, logWaterFlow, logChestAccess, logButtonsAndLevers, logKills, logChat, logSnowForm, logSnowFade, logDoors, logCakes, logEndermen;
|
||||
|
||||
public WorldConfig(File file) {
|
||||
public WorldConfig(File file) throws IOException {
|
||||
final Map<String, Object> def = new HashMap<String, Object>();
|
||||
def.put("table", "lb-" + file.getName().substring(0, file.getName().length() - 4));
|
||||
def.put("logBlockCreations", true);
|
||||
@@ -249,12 +272,11 @@ class WorldConfig
|
||||
def.put("logDoors", false);
|
||||
def.put("logCakes", false);
|
||||
def.put("logEndermen", false);
|
||||
final Configuration config = new Configuration(file);
|
||||
config.load();
|
||||
final YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
for (final Entry<String, Object> e : def.entrySet())
|
||||
if (config.getProperty(e.getKey()) == null)
|
||||
config.setProperty(e.getKey(), e.getValue());
|
||||
config.save();
|
||||
if (config.get(e.getKey()) == null)
|
||||
config.set(e.getKey(), e.getValue());
|
||||
config.save(file);
|
||||
table = config.getString("table");
|
||||
logBlockPlacings = config.getBoolean("logBlockCreations", true);
|
||||
logBlockBreaks = config.getBoolean("logBlockDestroyings", true);
|
||||
|
@@ -46,7 +46,7 @@ public class Consumer extends TimerTask
|
||||
Consumer(LogBlock logblock) {
|
||||
this.logblock = logblock;
|
||||
log = logblock.getServer().getLogger();
|
||||
config = logblock.getConfig();
|
||||
config = logblock.getLBConfig();
|
||||
hiddenPlayers = config.hiddenPlayers;
|
||||
hiddenBlocks = config.hiddenBlocks;
|
||||
worlds = config.worlds;
|
||||
|
@@ -35,7 +35,7 @@ class LBBlockListener extends BlockListener
|
||||
|
||||
LBBlockListener(LogBlock logblock) {
|
||||
consumer = logblock.getConsumer();
|
||||
worlds = logblock.getConfig().worlds;
|
||||
worlds = logblock.getLBConfig().worlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -32,9 +32,9 @@ class LBEntityListener extends EntityListener
|
||||
|
||||
LBEntityListener(LogBlock logblock) {
|
||||
consumer = logblock.getConsumer();
|
||||
worlds = logblock.getConfig().worlds;
|
||||
logCreeperExplosionsAsPlayer = logblock.getConfig().logCreeperExplosionsAsPlayerWhoTriggeredThese;
|
||||
logKillsLevel = logblock.getConfig().logKillsLevel;
|
||||
worlds = logblock.getLBConfig().worlds;
|
||||
logCreeperExplosionsAsPlayer = logblock.getLBConfig().logCreeperExplosionsAsPlayerWhoTriggeredThese;
|
||||
logKillsLevel = logblock.getLBConfig().logKillsLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -19,7 +19,7 @@ class LBPlayerListener extends PlayerListener
|
||||
|
||||
LBPlayerListener(LogBlock logblock) {
|
||||
consumer = logblock.getConsumer();
|
||||
worlds = logblock.getConfig().worlds;
|
||||
worlds = logblock.getLBConfig().worlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -25,8 +25,8 @@ class LBToolListener extends PlayerListener
|
||||
LBToolListener(LogBlock logblock) {
|
||||
this.logblock = logblock;
|
||||
handler = logblock.getCommandsHandler();
|
||||
worlds = logblock.getConfig().worlds;
|
||||
toolsByType = logblock.getConfig().toolsByType;
|
||||
worlds = logblock.getLBConfig().worlds;
|
||||
toolsByType = logblock.getLBConfig().toolsByType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ class LBToolListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||
final String[] split = event.getMessage().split(" ");
|
||||
if (split.length > 1 && split[0].equalsIgnoreCase("/ban") && logblock.hasPermission(event.getPlayer(), logblock.getConfig().banPermission)) {
|
||||
if (split.length > 1 && split[0].equalsIgnoreCase("/ban") && logblock.hasPermission(event.getPlayer(), logblock.getLBConfig().banPermission)) {
|
||||
final QueryParams p = new QueryParams(logblock);
|
||||
p.setPlayer(split[1].equalsIgnoreCase("g") ? split[2] : split[1]);
|
||||
p.since = 0;
|
||||
@@ -87,7 +87,7 @@ class LBToolListener extends PlayerListener
|
||||
@Override
|
||||
public void run() {
|
||||
for (final World world : logblock.getServer().getWorlds())
|
||||
if (logblock.getConfig().worlds.get(world.getName().hashCode()) != null) {
|
||||
if (worlds.get(world.getName().hashCode()) != null) {
|
||||
p.world = world;
|
||||
try {
|
||||
handler.new CommandRollback(event.getPlayer(), p, false);
|
||||
|
@@ -44,7 +44,7 @@ public class LogBlock extends JavaPlugin
|
||||
private boolean errorAtLoading = false;
|
||||
private final Map<Integer, Session> sessions = new HashMap<Integer, Session>();
|
||||
|
||||
public Config getConfig() {
|
||||
public Config getLBConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@@ -106,7 +106,7 @@ public class QueryParams implements Cloneable
|
||||
}
|
||||
|
||||
public String getTable() {
|
||||
return logblock.getConfig().worlds.get(world.getName().hashCode()).table;
|
||||
return logblock.getLBConfig().worlds.get(world.getName().hashCode()).table;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@@ -303,7 +303,7 @@ public class QueryParams implements Cloneable
|
||||
if (player == null && !prepareToolQuery)
|
||||
throw new IllegalArgumentException("You have to ba a player to use area");
|
||||
if (values == null) {
|
||||
radius = logblock.getConfig().defaultDist;
|
||||
radius = logblock.getLBConfig().defaultDist;
|
||||
if (!prepareToolQuery)
|
||||
loc = player.getLocation();
|
||||
} else {
|
||||
@@ -327,14 +327,14 @@ public class QueryParams implements Cloneable
|
||||
setSelection(selection);
|
||||
} else if (param.equals("time") || param.equals("since")) {
|
||||
if (values.length == 0)
|
||||
since = logblock.getConfig().defaultTime;
|
||||
since = logblock.getLBConfig().defaultTime;
|
||||
else
|
||||
since = parseTimeSpec(values);
|
||||
if (since == -1)
|
||||
throw new IllegalArgumentException("Failed to parse time spec for '" + param + "'");
|
||||
} else if (param.equals("before")) {
|
||||
if (values.length == 0)
|
||||
before = logblock.getConfig().defaultTime;
|
||||
before = logblock.getLBConfig().defaultTime;
|
||||
else
|
||||
before = parseTimeSpec(values);
|
||||
if (before == -1)
|
||||
@@ -406,7 +406,7 @@ public class QueryParams implements Cloneable
|
||||
if (!prepareToolQuery && bct != BlockChangeType.CHAT) {
|
||||
if (world == null)
|
||||
throw new IllegalArgumentException("No world specified");
|
||||
if (!logblock.getConfig().worlds.containsKey(world.getName().hashCode()))
|
||||
if (!logblock.getLBConfig().worlds.containsKey(world.getName().hashCode()))
|
||||
throw new IllegalArgumentException("This world ('" + world.getName() + "') isn't logged");
|
||||
}
|
||||
if (session != null)
|
||||
@@ -459,7 +459,7 @@ public class QueryParams implements Cloneable
|
||||
loc = p.loc;
|
||||
radius = p.radius;
|
||||
sel = p.sel;
|
||||
if (p.since != 0 || since != logblock.getConfig().defaultTime)
|
||||
if (p.since != 0 || since != logblock.getLBConfig().defaultTime)
|
||||
since = p.since;
|
||||
before = p.before;
|
||||
sum = p.sum;
|
||||
|
@@ -14,7 +14,7 @@ public class Session
|
||||
Session(LogBlock logblock, Player player) {
|
||||
toolData = new HashMap<Tool, ToolData>();
|
||||
if (player != null)
|
||||
for (final Tool tool : logblock.getConfig().toolsByType.values())
|
||||
for (final Tool tool : logblock.getLBConfig().toolsByType.values())
|
||||
toolData.put(tool, new ToolData(tool, logblock, player));
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,15 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
||||
import static de.diddiz.util.Utils.readURL;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
class Updater
|
||||
{
|
||||
@@ -25,70 +22,12 @@ class Updater
|
||||
}
|
||||
|
||||
boolean update() {
|
||||
final Configuration config = logblock.getConfiguration();
|
||||
config.load();
|
||||
final ConfigurationSection config = logblock.getConfig();
|
||||
if (config.getString("version").compareTo(logblock.getDescription().getVersion()) >= 0)
|
||||
return false;
|
||||
if (config.getString("version").compareTo("1.10") < 0) {
|
||||
log.info("[LogBlock] Updating config to 1.10 ...");
|
||||
String params = config.getString("lookup.toolQuery");
|
||||
if (!params.contains("silent"))
|
||||
config.setProperty("lookup.toolQuery", params + " silent");
|
||||
params = config.getString("lookup.toolBlockQuery");
|
||||
if (!params.contains("silent"))
|
||||
config.setProperty("lookup.toolBlockQuery", params + " silent");
|
||||
config.setProperty("version", "1.10");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.20") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.20 ...");
|
||||
final Connection conn = logblock.getConnection();
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
final Statement st = conn.createStatement();
|
||||
for (final String table : config.getStringList("tables", null))
|
||||
st.execute("ALTER TABLE `" + table + "-sign` MODIFY signtext VARCHAR(255) NOT NULL");
|
||||
st.close();
|
||||
conn.close();
|
||||
} catch (final SQLException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "[LogBlock Updater] Error: ", ex);
|
||||
return false;
|
||||
}
|
||||
config.setProperty("version", "1.20");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.23") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.23 ...");
|
||||
final Connection conn = logblock.getConnection();
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
final Statement st = conn.createStatement();
|
||||
for (final String table : config.getStringList("tables", null))
|
||||
if (st.executeQuery("SELECT * FROM `" + table + "-chest` LIMIT 1").getMetaData().getColumnCount() != 4)
|
||||
st.execute("DROP TABLE `" + table + "-chest`");
|
||||
st.close();
|
||||
conn.close();
|
||||
} catch (final SQLException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "[LogBlock Updater] Error: ", ex);
|
||||
return false;
|
||||
}
|
||||
log.info("[LogBlock] Updating config to 1.23 ...");
|
||||
final List<String> worldNames = config.getStringList("loggedWorlds", null), worldTables = config.getStringList("tables", null);
|
||||
final String[] nodes = new String[]{"BlockCreations", "BlockDestroyings", "SignTexts", "Explosions", "Fire", "LeavesDecay", "LavaFlow", "ChestAccess", "ButtonsAndLevers", "Kills", "Chat"};
|
||||
for (int i = 0; i < worldNames.size(); i++) {
|
||||
final Configuration wcfg = new Configuration(new File("plugins/LogBlock/" + friendlyWorldname(worldNames.get(i)) + ".yml"));
|
||||
wcfg.load();
|
||||
wcfg.setProperty("table", worldTables.get(i));
|
||||
for (final String node : nodes)
|
||||
wcfg.setProperty("log" + node, config.getBoolean("logging.log" + node, true));
|
||||
wcfg.save();
|
||||
}
|
||||
for (final String node : nodes)
|
||||
config.removeProperty("logging.log" + node);
|
||||
config.removeProperty("tables");
|
||||
config.setProperty("version", "1.23");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.27") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.27 ...");
|
||||
if (logblock.getConfig().logChat) {
|
||||
if (logblock.getLBConfig().logChat) {
|
||||
final Connection conn = logblock.getConnection();
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
@@ -101,14 +40,14 @@ class Updater
|
||||
return false;
|
||||
}
|
||||
}
|
||||
config.setProperty("version", "1.27");
|
||||
config.set("version", "1.27");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.30") < 0) {
|
||||
log.info("[LogBlock] Updating config to 1.30 ...");
|
||||
for (final String tool : config.getKeys("tools"))
|
||||
if (config.getProperty("tools." + tool + ".permissionDefault") == null)
|
||||
config.setProperty("tools." + tool + ".permissionDefault", "OP");
|
||||
config.setProperty("version", "1.30");
|
||||
for (final String tool : config.getConfigurationSection("tools").getKeys(false))
|
||||
if (config.get("tools." + tool + ".permissionDefault") == null)
|
||||
config.set("tools." + tool + ".permissionDefault", "OP");
|
||||
config.set("version", "1.30");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.31") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.31 ...");
|
||||
@@ -123,7 +62,7 @@ class Updater
|
||||
Bukkit.getLogger().log(Level.SEVERE, "[LogBlock Updater] Error: ", ex);
|
||||
return false;
|
||||
}
|
||||
config.setProperty("version", "1.31");
|
||||
config.set("version", "1.31");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.32") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.32 ...");
|
||||
@@ -138,9 +77,9 @@ class Updater
|
||||
Bukkit.getLogger().log(Level.SEVERE, "[LogBlock Updater] Error: ", ex);
|
||||
return false;
|
||||
}
|
||||
config.setProperty("version", "1.32");
|
||||
config.set("version", "1.32");
|
||||
}
|
||||
config.save();
|
||||
logblock.saveConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -152,9 +91,9 @@ class Updater
|
||||
final DatabaseMetaData dbm = conn.getMetaData();
|
||||
conn.setAutoCommit(true);
|
||||
createTable(dbm, state, "lb-players", "(playerid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, playername varchar(32) NOT NULL, firstlogin DATETIME NOT NULL, lastlogin DATETIME NOT NULL, onlinetime TIME NOT NULL, ip varchar(255) NOT NULL, PRIMARY KEY (playerid), UNIQUE (playername))");
|
||||
if (logblock.getConfig().logChat)
|
||||
if (logblock.getLBConfig().logChat)
|
||||
createTable(dbm, state, "lb-chat", "(id INT UNSIGNED NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, playerid SMALLINT UNSIGNED NOT NULL, message VARCHAR(255) NOT NULL, PRIMARY KEY (id), KEY playerid (playerid), FULLTEXT message (message)) ENGINE=MyISAM");
|
||||
for (final WorldConfig wcfg : logblock.getConfig().worlds.values()) {
|
||||
for (final WorldConfig wcfg : logblock.getLBConfig().worlds.values()) {
|
||||
createTable(dbm, state, wcfg.table, "(id INT UNSIGNED NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, playerid SMALLINT UNSIGNED NOT NULL, replaced TINYINT UNSIGNED NOT NULL, type TINYINT UNSIGNED NOT NULL, data TINYINT UNSIGNED NOT NULL, x SMALLINT NOT NULL, y TINYINT UNSIGNED NOT NULL, z SMALLINT NOT NULL, PRIMARY KEY (id), KEY coords (x, z, y), KEY date (date), KEY playerid (playerid))");
|
||||
createTable(dbm, state, wcfg.table + "-sign", "(id INT UNSIGNED NOT NULL, signtext VARCHAR(255) NOT NULL, PRIMARY KEY (id))");
|
||||
createTable(dbm, state, wcfg.table + "-chest", "(id INT UNSIGNED NOT NULL, itemtype SMALLINT UNSIGNED NOT NULL, itemamount SMALLINT NOT NULL, itemdata TINYINT UNSIGNED NOT NULL, PRIMARY KEY (id))");
|
||||
|
@@ -39,7 +39,7 @@ public class WorldEditor implements Runnable
|
||||
public WorldEditor(LogBlock logblock, World world) {
|
||||
log = logblock.getServer().getLogger();
|
||||
this.logblock = logblock;
|
||||
config = logblock.getConfig();
|
||||
config = logblock.getLBConfig();
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user