forked from LogBlock/LogBlock
Switched to static getLogger instead of a local variable
This commit is contained in:
@@ -4,6 +4,7 @@ import static de.diddiz.util.BukkitUtils.giveTool;
|
||||
import static de.diddiz.util.BukkitUtils.saveSpawnHeight;
|
||||
import static de.diddiz.util.BukkitUtils.senderName;
|
||||
import static de.diddiz.util.Utils.isInt;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@@ -16,7 +17,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -32,7 +32,6 @@ import de.diddiz.LogBlockQuestioner.LogBlockQuestioner;
|
||||
|
||||
public class CommandsHandler implements CommandExecutor
|
||||
{
|
||||
private final Logger log;
|
||||
private final LogBlock logblock;
|
||||
private final Config config;
|
||||
private final BukkitScheduler scheduler;
|
||||
@@ -40,7 +39,6 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
CommandsHandler(LogBlock logblock) {
|
||||
this.logblock = logblock;
|
||||
log = logblock.getServer().getLogger();
|
||||
config = logblock.getLBConfig();
|
||||
scheduler = logblock.getServer().getScheduler();
|
||||
questioner = (LogBlockQuestioner)logblock.getServer().getPluginManager().getPlugin("LogBlockQuestioner");
|
||||
@@ -307,7 +305,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
}
|
||||
} catch (final NullPointerException ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Error, check log");
|
||||
log.log(Level.WARNING, "[LogBlock] NPE in commandshandler: ", ex);
|
||||
getLogger().log(Level.WARNING, "[LogBlock] NPE in commandshandler: ", ex);
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + ex.getMessage());
|
||||
}
|
||||
@@ -374,7 +372,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
if (rs != null)
|
||||
rs.close();
|
||||
} catch (final SQLException ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock CommandsHandler] SQL exception on close", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock CommandsHandler] SQL exception on close", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -424,7 +422,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||
log.log(Level.SEVERE, "[LogBlock Lookup] " + params.getQuery() + ": ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Lookup] " + params.getQuery() + ": ", ex);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
@@ -477,7 +475,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
sender.sendMessage(ChatColor.GREEN + "Wrote " + counter + " lines.");
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||
log.log(Level.SEVERE, "[LogBlock WriteLogFile] " + params.getQuery() + " (file was " + file.getAbsolutePath() + "): ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock WriteLogFile] " + params.getQuery() + " (file was " + file.getAbsolutePath() + "): ", ex);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
@@ -537,7 +535,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
sender.sendMessage(ChatColor.RED + "No block change found to teleport to");
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||
log.log(Level.SEVERE, "[LogBlock Teleport] " + params.getQuery() + ": ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Teleport] " + params.getQuery() + ": ", ex);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
@@ -597,7 +595,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||
log.log(Level.SEVERE, "[LogBlock Rollback] " + params.getQuery() + ": ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Rollback] " + params.getQuery() + ": ", ex);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
@@ -646,7 +644,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
sender.sendMessage(ChatColor.GREEN + "Redo finished successfully (" + editor.getElapsedTime() + " ms, " + editor.getSuccesses() + "/" + changes + " blocks" + (editor.getErrors() > 0 ? ", " + ChatColor.RED + editor.getErrors() + " errors" + ChatColor.GREEN : "") + (editor.getBlacklistCollisions() > 0 ? ", " + editor.getBlacklistCollisions() + " blacklist collisions" : "") + ")");
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||
log.log(Level.SEVERE, "[LogBlock Redo] " + params.getQuery() + ": ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Redo] " + params.getQuery() + ": ", ex);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
@@ -689,7 +687,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
state.execute("SELECT * FROM `" + table + "` " + join + params.getWhere() + "INTO OUTFILE '" + new File(dumpFolder, time + " " + table + " " + params.getTitle().replace(":", ".") + ".csv").getAbsolutePath().replace("\\", "\\\\") + "' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n'");
|
||||
} catch (final SQLException ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Error while dumping log. Make sure your MySQL user has access to the LogBlock folder, or disable clearlog.dumpDeletedLog");
|
||||
log.log(Level.SEVERE, "[LogBlock ClearLog] Exception while dumping log: ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock ClearLog] Exception while dumping log: ", ex);
|
||||
return;
|
||||
}
|
||||
state.execute("DELETE `" + table + "` FROM `" + table + "` " + join + params.getWhere());
|
||||
@@ -713,7 +711,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||
log.log(Level.SEVERE, "[LogBlock ClearLog] Exception: ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock ClearLog] Exception: ", ex);
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package de.diddiz.LogBlock;
|
||||
|
||||
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
||||
import static de.diddiz.util.Utils.parseTimeSpec;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -164,7 +165,7 @@ public class Config
|
||||
final PermissionDefault pdef = PermissionDefault.valueOf(config.getString(path + ".permissionDefault").toUpperCase());
|
||||
tools.add(new Tool(toolName, aliases, leftClickBehavior, rightClickBehavior, defaultEnabled, item, params, mode, pdef));
|
||||
} catch (final Exception ex) {
|
||||
Bukkit.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>();
|
||||
toolsByType = new HashMap<Integer, Tool>();
|
||||
@@ -241,7 +242,7 @@ public class Config
|
||||
try {
|
||||
ints.add(Integer.valueOf(String.valueOf(obj)));
|
||||
} catch (final NumberFormatException ex) {
|
||||
Bukkit.getLogger().warning("[LogBlock] Config error: '" + obj + "' is not a number");
|
||||
getLogger().warning("[LogBlock] Config error: '" + obj + "' is not a number");
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package de.diddiz.LogBlock;
|
||||
import static de.diddiz.util.BukkitUtils.compressInventory;
|
||||
import static de.diddiz.util.BukkitUtils.entityName;
|
||||
import static de.diddiz.util.BukkitUtils.rawData;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
@@ -20,7 +21,6 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -38,14 +38,12 @@ public class Consumer extends TimerTask
|
||||
private final Map<Integer, WorldConfig> worlds;
|
||||
private final Set<Integer> hiddenPlayers, hiddenBlocks;
|
||||
private final Set<String> failedPlayers = new HashSet<String>();
|
||||
private final Logger log;
|
||||
private final LogBlock logblock;
|
||||
private final Map<Integer, Integer> players = new HashMap<Integer, Integer>();
|
||||
private final Lock lock = new ReentrantLock();
|
||||
|
||||
Consumer(LogBlock logblock) {
|
||||
this.logblock = logblock;
|
||||
log = logblock.getServer().getLogger();
|
||||
config = logblock.getLBConfig();
|
||||
hiddenPlayers = config.hiddenPlayers;
|
||||
hiddenBlocks = config.hiddenBlocks;
|
||||
@@ -252,7 +250,7 @@ public class Consumer extends TimerTask
|
||||
final Connection conn = logblock.getConnection();
|
||||
Statement state = null;
|
||||
if (getQueueSize() > 1000)
|
||||
log.info("[LogBlock Consumer] Queue overloaded. Size: " + getQueueSize());
|
||||
getLogger().info("[LogBlock Consumer] Queue overloaded. Size: " + getQueueSize());
|
||||
try {
|
||||
if (conn == null)
|
||||
return;
|
||||
@@ -269,7 +267,7 @@ public class Consumer extends TimerTask
|
||||
if (!addPlayer(state, player)) {
|
||||
if (!failedPlayers.contains(player)) {
|
||||
failedPlayers.add(player);
|
||||
log.warning("[LogBlock Consumer] Failed to add player " + player);
|
||||
getLogger().warning("[LogBlock Consumer] Failed to add player " + player);
|
||||
}
|
||||
continue process;
|
||||
}
|
||||
@@ -277,14 +275,14 @@ public class Consumer extends TimerTask
|
||||
try {
|
||||
state.execute(insert);
|
||||
} catch (final SQLException ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock Consumer] SQL exception on " + insert + ": ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Consumer] SQL exception on " + insert + ": ", ex);
|
||||
break process;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
conn.commit();
|
||||
} catch (final SQLException ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock Consumer] SQL exception", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Consumer] SQL exception", ex);
|
||||
} finally {
|
||||
try {
|
||||
if (state != null)
|
||||
@@ -292,7 +290,7 @@ public class Consumer extends TimerTask
|
||||
if (conn != null)
|
||||
conn.close();
|
||||
} catch (final SQLException ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock Consumer] SQL exception on close", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock Consumer] SQL exception on close", ex);
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import static de.diddiz.util.Utils.download;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -17,7 +18,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -33,7 +33,6 @@ import de.diddiz.util.MySQLConnectionPool;
|
||||
|
||||
public class LogBlock extends JavaPlugin
|
||||
{
|
||||
private Logger log;
|
||||
private Config config;
|
||||
private MySQLConnectionPool pool;
|
||||
private Consumer consumer = null;
|
||||
@@ -62,18 +61,17 @@ public class LogBlock extends JavaPlugin
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
log = getServer().getLogger();
|
||||
try {
|
||||
updater = new Updater(this);
|
||||
config = new Config(this);
|
||||
if (config.checkVersion)
|
||||
log.info("[LogBlock] Version check: " + updater.checkVersion());
|
||||
getLogger().info("[LogBlock] Version check: " + updater.checkVersion());
|
||||
final File file = new File("lib/mysql-connector-java-bin.jar");
|
||||
if (!file.exists() || file.length() == 0)
|
||||
download(log, new URL("http://diddiz.insane-architects.net/download/mysql-connector-java-bin.jar"), file);
|
||||
download(getLogger(), new URL("http://diddiz.insane-architects.net/download/mysql-connector-java-bin.jar"), file);
|
||||
if (!file.exists() || file.length() == 0)
|
||||
throw new FileNotFoundException(file.getAbsolutePath() + file.getName());
|
||||
log.info("[LogBlock] Connecting to " + config.user + "@" + config.url + "...");
|
||||
getLogger().info("[LogBlock] Connecting to " + config.user + "@" + config.url + "...");
|
||||
pool = new MySQLConnectionPool(config.url, config.user, config.password);
|
||||
getConnection().close();
|
||||
if (updater.update())
|
||||
@@ -86,7 +84,7 @@ public class LogBlock extends JavaPlugin
|
||||
}
|
||||
});
|
||||
if (imports != null && imports.length > 0) {
|
||||
log.info("[LogBlock] Found " + imports.length + "imports.");
|
||||
getLogger().info("[LogBlock] Found " + imports.length + "imports.");
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = getConnection();
|
||||
@@ -94,7 +92,7 @@ public class LogBlock extends JavaPlugin
|
||||
final Statement st = conn.createStatement();
|
||||
for (final File sqlFile : imports)
|
||||
try {
|
||||
log.info("[LogBlock] Trying to import " + sqlFile.getName() + " ...");
|
||||
getLogger().info("[LogBlock] Trying to import " + sqlFile.getName() + " ...");
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(sqlFile));
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null)
|
||||
@@ -103,22 +101,22 @@ public class LogBlock extends JavaPlugin
|
||||
conn.commit();
|
||||
reader.close();
|
||||
sqlFile.delete();
|
||||
log.info("[LogBlock] Successfully imported " + sqlFile.getName() + ".");
|
||||
getLogger().info("[LogBlock] Successfully imported " + sqlFile.getName() + ".");
|
||||
} catch (final Exception ex) {
|
||||
log.log(Level.WARNING, "[LogBlock] Failed to import " + sqlFile.getName() + ": ", ex);
|
||||
getLogger().log(Level.WARNING, "[LogBlock] Failed to import " + sqlFile.getName() + ": ", ex);
|
||||
file.renameTo(new File("plugins/LogBlock/import/" + sqlFile.getName() + ".failed"));
|
||||
}
|
||||
st.close();
|
||||
log.info("[LogBlock] Successfully imported stored queue.");
|
||||
getLogger().info("[LogBlock] Successfully imported stored queue.");
|
||||
} catch (final Exception ex) {
|
||||
log.log(Level.WARNING, "[LogBlock] Error while importing: ", ex);
|
||||
getLogger().log(Level.WARNING, "[LogBlock] Error while importing: ", ex);
|
||||
} finally {
|
||||
if (conn != null)
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock] Error while loading: ", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock] Error while loading: ", ex);
|
||||
errorAtLoading = true;
|
||||
return;
|
||||
}
|
||||
@@ -134,34 +132,34 @@ public class LogBlock extends JavaPlugin
|
||||
}
|
||||
if (pm.getPlugin("WorldEdit") == null && !new File("lib/WorldEdit.jar").exists() && !new File("WorldEdit.jar").exists())
|
||||
try {
|
||||
download(log, new URL("http://diddiz.insane-architects.net/download/WorldEdit.jar"), new File("lib/WorldEdit.jar"));
|
||||
log.info("[LogBlock] You've to restart/reload your server now.");
|
||||
download(getLogger(), new URL("http://diddiz.insane-architects.net/download/WorldEdit.jar"), new File("lib/WorldEdit.jar"));
|
||||
getLogger().info("[LogBlock] You've to restart/reload your server now.");
|
||||
pm.disablePlugin(this);
|
||||
return;
|
||||
} catch (final Exception ex) {
|
||||
log.warning("[LogBlock] Failed to download WorldEdit. You may have to download it manually. You don't have to install it, just place the jar in the lib folder.");
|
||||
getLogger().warning("[LogBlock] Failed to download WorldEdit. You may have to download it manually. You don't have to install it, just place the jar in the lib folder.");
|
||||
}
|
||||
if (config.logChestAccess && pm.getPlugin("Spout") == null)
|
||||
if (config.installSpout)
|
||||
try {
|
||||
download(log, new URL("http://ci.getspout.org/job/Spout/Recommended/artifact/target/spout-dev-SNAPSHOT.jar"), new File("plugins/Spout.jar"));
|
||||
download(getLogger(), new URL("http://ci.getspout.org/job/Spout/Recommended/artifact/target/spout-dev-SNAPSHOT.jar"), new File("plugins/Spout.jar"));
|
||||
pm.loadPlugin(new File("plugins/Spout.jar"));
|
||||
pm.enablePlugin(pm.getPlugin("Spout"));
|
||||
} catch (final Exception ex) {
|
||||
config.logChestAccess = false;
|
||||
log.warning("[LogBlock] Failed to install Spout, you may have to restart your server or install it manually.");
|
||||
getLogger().warning("[LogBlock] Failed to install Spout, you may have to restart your server or install it manually.");
|
||||
}
|
||||
else {
|
||||
config.logChestAccess = false;
|
||||
log.warning("[LogBlock] Spout is not installed. Disabling chest logging.");
|
||||
getLogger().warning("[LogBlock] Spout is not installed. Disabling chest logging.");
|
||||
}
|
||||
commandsHandler = new CommandsHandler(this);
|
||||
getCommand("lb").setExecutor(commandsHandler);
|
||||
if (pm.getPlugin("Permissions") != null) {
|
||||
permissions = ((Permissions)pm.getPlugin("Permissions")).getHandler();
|
||||
log.info("[LogBlock] Permissions plugin found.");
|
||||
getLogger().info("[LogBlock] Permissions plugin found.");
|
||||
} else
|
||||
log.info("[LogBlock] Permissions plugin not found. Using Bukkit Permissions.");
|
||||
getLogger().info("[LogBlock] Permissions plugin not found. Using Bukkit Permissions.");
|
||||
if (config.keepLogDays >= 0) {
|
||||
final QueryParams params = new QueryParams(this);
|
||||
params.before = config.keepLogDays * 1440;
|
||||
@@ -172,7 +170,7 @@ public class LogBlock extends JavaPlugin
|
||||
try {
|
||||
commandsHandler.new CommandClearLog(getServer().getConsoleSender(), params.clone(), true);
|
||||
} catch (final Exception ex) {
|
||||
log.severe("Failed to schedule ClearLog: " + ex.getMessage());
|
||||
getLogger().log(Level.SEVERE, "Failed to schedule ClearLog: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,7 +207,7 @@ public class LogBlock extends JavaPlugin
|
||||
if (pm.getPlugin("Spout") != null)
|
||||
pm.registerEvent(Type.CUSTOM_EVENT, new LBChestAccessListener(this), Priority.Monitor, this);
|
||||
else
|
||||
log.warning("[LogBlock] BukkitContrib not found. Can't log chest accesses.");
|
||||
getLogger().warning("[LogBlock] BukkitContrib not found. Can't log chest accesses.");
|
||||
if (config.logButtonsAndLevers || config.logDoors || config.logCakes)
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, lbPlayerListener, Priority.Monitor, this);
|
||||
if (config.logKills)
|
||||
@@ -229,23 +227,23 @@ public class LogBlock extends JavaPlugin
|
||||
}
|
||||
if (config.useBukkitScheduler) {
|
||||
if (getServer().getScheduler().scheduleAsyncRepeatingTask(this, consumer, config.delayBetweenRuns * 20, config.delayBetweenRuns * 20) > 0)
|
||||
log.info("[LogBlock] Scheduled consumer with bukkit scheduler.");
|
||||
getLogger().info("[LogBlock] Scheduled consumer with bukkit scheduler.");
|
||||
else {
|
||||
log.warning("[LogBlock] Failed to schedule consumer with bukkit scheduler. Now trying schedule with timer.");
|
||||
getLogger().warning("[LogBlock] Failed to schedule consumer with bukkit scheduler. Now trying schedule with timer.");
|
||||
timer = new Timer();
|
||||
timer.scheduleAtFixedRate(consumer, config.delayBetweenRuns * 1000, config.delayBetweenRuns * 1000);
|
||||
}
|
||||
} else {
|
||||
timer = new Timer();
|
||||
timer.scheduleAtFixedRate(consumer, config.delayBetweenRuns * 1000, config.delayBetweenRuns * 1000);
|
||||
log.info("[LogBlock] Scheduled consumer with timer.");
|
||||
getLogger().info("[LogBlock] Scheduled consumer with timer.");
|
||||
}
|
||||
for (final Tool tool : config.toolsByType.values()) {
|
||||
final Permission perm = new Permission("logblock.tools." + tool.name, tool.permissionDefault);
|
||||
pm.addPermission(perm);
|
||||
// perm.addParent("logblock.*", true);
|
||||
}
|
||||
log.info("LogBlock v" + getDescription().getVersion() + " by DiddiZ enabled.");
|
||||
getLogger().info("LogBlock v" + getDescription().getVersion() + " by DiddiZ enabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,21 +255,21 @@ public class LogBlock extends JavaPlugin
|
||||
for (final Player player : getServer().getOnlinePlayers())
|
||||
consumer.queueLeave(player);
|
||||
if (consumer != null && consumer.getQueueSize() > 0) {
|
||||
log.info("[LogBlock] Waiting for consumer ...");
|
||||
getLogger().info("[LogBlock] Waiting for consumer ...");
|
||||
int lastSize = -1, fails = 0;
|
||||
while (consumer.getQueueSize() > 0) {
|
||||
log.info("[LogBlock] Remaining queue size: " + consumer.getQueueSize());
|
||||
getLogger().info("[LogBlock] Remaining queue size: " + consumer.getQueueSize());
|
||||
if (lastSize == consumer.getQueueSize()) {
|
||||
fails++;
|
||||
log.info("[LogBlock] Remaining tries: " + (10 - fails));
|
||||
getLogger().info("[LogBlock] Remaining tries: " + (10 - fails));
|
||||
} else
|
||||
fails = 0;
|
||||
if (fails == 10) {
|
||||
log.info("Unable to save queue to database. Trying to write to a local file.");
|
||||
getLogger().info("Unable to save queue to database. Trying to write to a local file.");
|
||||
try {
|
||||
consumer.writeToFile();
|
||||
} catch (final FileNotFoundException ex) {
|
||||
log.info("Failed to write. Given up.");
|
||||
getLogger().info("Failed to write. Given up.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -281,7 +279,7 @@ public class LogBlock extends JavaPlugin
|
||||
}
|
||||
if (pool != null)
|
||||
pool.close();
|
||||
log.info("LogBlock disabled.");
|
||||
getLogger().info("LogBlock disabled.");
|
||||
}
|
||||
|
||||
boolean hasPermission(CommandSender sender, String permission) {
|
||||
@@ -294,7 +292,7 @@ public class LogBlock extends JavaPlugin
|
||||
try {
|
||||
return pool.getConnection();
|
||||
} catch (final Exception ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock] Error while fetching connection", ex);
|
||||
getLogger().log(Level.SEVERE, "[LogBlock] Error while fetching connection", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +1,22 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import static de.diddiz.util.Utils.readURL;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
class Updater
|
||||
{
|
||||
private final Logger log;
|
||||
private final LogBlock logblock;
|
||||
|
||||
Updater(LogBlock logblock) {
|
||||
this.logblock = logblock;
|
||||
log = logblock.getServer().getLogger();
|
||||
}
|
||||
|
||||
boolean update() {
|
||||
@@ -26,7 +24,7 @@ class Updater
|
||||
if (config.getString("version").compareTo(logblock.getDescription().getVersion()) >= 0)
|
||||
return false;
|
||||
if (config.getString("version").compareTo("1.27") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.27 ...");
|
||||
getLogger().info("[LogBlock] Updating tables to 1.27 ...");
|
||||
if (logblock.getLBConfig().logChat) {
|
||||
final Connection conn = logblock.getConnection();
|
||||
try {
|
||||
@@ -43,14 +41,14 @@ class Updater
|
||||
config.set("version", "1.27");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.30") < 0) {
|
||||
log.info("[LogBlock] Updating config to 1.30 ...");
|
||||
getLogger().info("[LogBlock] Updating config to 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 ...");
|
||||
getLogger().info("[LogBlock] Updating tables to 1.31 ...");
|
||||
final Connection conn = logblock.getConnection();
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
@@ -65,7 +63,7 @@ class Updater
|
||||
config.set("version", "1.31");
|
||||
}
|
||||
if (config.getString("version").compareTo("1.32") < 0) {
|
||||
log.info("[LogBlock] Updating tables to 1.32 ...");
|
||||
getLogger().info("[LogBlock] Updating tables to 1.32 ...");
|
||||
final Connection conn = logblock.getConnection();
|
||||
try {
|
||||
conn.setAutoCommit(true);
|
||||
@@ -106,7 +104,7 @@ class Updater
|
||||
|
||||
private void createTable(DatabaseMetaData dbm, Statement state, String table, String query) throws SQLException {
|
||||
if (!dbm.getTables(null, null, table, null).next()) {
|
||||
log.log(Level.INFO, "[LogBlock] Creating table " + table + ".");
|
||||
getLogger().log(Level.INFO, "[LogBlock] Creating table " + table + ".");
|
||||
state.execute("CREATE TABLE `" + table + "` " + query);
|
||||
if (!dbm.getTables(null, null, table, null).next())
|
||||
throw new SQLException("Table " + table + " not found and failed to create");
|
||||
|
@@ -3,6 +3,7 @@ package de.diddiz.LogBlock;
|
||||
import static de.diddiz.util.BukkitUtils.equalTypes;
|
||||
import static de.diddiz.util.BukkitUtils.materialName;
|
||||
import static de.diddiz.util.BukkitUtils.modifyContainer;
|
||||
import static org.bukkit.Bukkit.getLogger;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -11,7 +12,6 @@ import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -26,7 +26,6 @@ import org.bukkit.material.PistonExtensionMaterial;
|
||||
|
||||
public class WorldEditor implements Runnable
|
||||
{
|
||||
private final Logger log;
|
||||
private final LogBlock logblock;
|
||||
private final Config config;
|
||||
private final Queue<Edit> edits = new LinkedBlockingQueue<Edit>();
|
||||
@@ -37,7 +36,6 @@ public class WorldEditor implements Runnable
|
||||
public LookupCacheElement[] errors;
|
||||
|
||||
public WorldEditor(LogBlock logblock, World world) {
|
||||
log = logblock.getServer().getLogger();
|
||||
this.logblock = logblock;
|
||||
config = logblock.getLBConfig();
|
||||
this.world = world;
|
||||
@@ -97,7 +95,7 @@ public class WorldEditor implements Runnable
|
||||
} catch (final WorldEditorException ex) {
|
||||
errorList.add(ex);
|
||||
} catch (final Exception ex) {
|
||||
log.log(Level.WARNING, "[LogBlock WorldEditor] Exeption: ", ex);
|
||||
getLogger().log(Level.WARNING, "[LogBlock WorldEditor] Exeption: ", ex);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user