Ensure formatting is consistant across all files.

This commit is contained in:
md_5
2012-06-23 18:16:23 +10:00
parent f1ea45ce83
commit 722c930e85
15 changed files with 315 additions and 295 deletions

View File

@@ -30,11 +30,11 @@ import java.util.logging.Level;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class Consumer extends TimerTask public class Consumer extends TimerTask
@@ -49,7 +49,8 @@ public class Consumer extends TimerTask
this.logblock = logblock; this.logblock = logblock;
try { try {
Class.forName("PlayerLeaveRow"); Class.forName("PlayerLeaveRow");
} catch (final ClassNotFoundException ex) {} } catch (final ClassNotFoundException ex) {
}
} }
/** /**
@@ -274,7 +275,8 @@ public class Consumer extends TimerTask
state = conn.createStatement(); state = conn.createStatement();
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
int count = 0; int count = 0;
process: while (!queue.isEmpty() && (System.currentTimeMillis() - start < timePerRun || count < forceToProcessAtLeast)) { process:
while (!queue.isEmpty() && (System.currentTimeMillis() - start < timePerRun || count < forceToProcessAtLeast)) {
final Row r = queue.poll(); final Row r = queue.poll();
if (r == null) if (r == null)
continue; continue;

View File

@@ -62,7 +62,8 @@ public class DumpedLogImporter implements Runnable
if (conn != null) if (conn != null)
try { try {
conn.close(); conn.close();
} catch (final SQLException ex) {} } catch (final SQLException ex) {
}
} }
} }
} }

View File

@@ -56,255 +56,255 @@ import de.diddiz.util.MySQLConnectionPool;
public class LogBlock extends JavaPlugin public class LogBlock extends JavaPlugin
{ {
private static LogBlock logblock = null; private static LogBlock logblock = null;
private MySQLConnectionPool pool; private MySQLConnectionPool pool;
private Consumer consumer = null; private Consumer consumer = null;
private CommandsHandler commandsHandler; private CommandsHandler commandsHandler;
private Updater updater = null; private Updater updater = null;
private Timer timer = null; private Timer timer = null;
private boolean errorAtLoading = false, noDb = false, connected = true; private boolean errorAtLoading = false, noDb = false, connected = true;
public static LogBlock getInstance() { public static LogBlock getInstance() {
return logblock; return logblock;
} }
public Consumer getConsumer() { public Consumer getConsumer() {
return consumer; return consumer;
} }
public CommandsHandler getCommandsHandler() { public CommandsHandler getCommandsHandler() {
return commandsHandler; return commandsHandler;
} }
Updater getUpdater() { Updater getUpdater() {
return updater; return updater;
} }
@Override @Override
public void onLoad() { public void onLoad() {
logblock = this; logblock = this;
try { try {
updater = new Updater(this); updater = new Updater(this);
Config.load(this); Config.load(this);
if (checkVersion) if (checkVersion)
getLogger().info("[LogBlock] Version check: " + updater.checkVersion()); getLogger().info("[LogBlock] Version check: " + updater.checkVersion());
getLogger().info("[LogBlock] Connecting to " + user + "@" + url + "..."); getLogger().info("[LogBlock] Connecting to " + user + "@" + url + "...");
pool = new MySQLConnectionPool(url, user, password); pool = new MySQLConnectionPool(url, user, password);
final Connection conn = getConnection(); final Connection conn = getConnection();
if (conn == null) { if (conn == null) {
noDb = true; noDb = true;
return; return;
} }
conn.close(); conn.close();
if (updater.update()) if (updater.update())
load(this); load(this);
updater.checkTables(); updater.checkTables();
} catch (final NullPointerException ex) { } catch (final NullPointerException ex) {
getLogger().log(Level.SEVERE, "[LogBlock] Error while loading: ", ex); getLogger().log(Level.SEVERE, "[LogBlock] Error while loading: ", ex);
} catch (final Exception ex) { } catch (final Exception ex) {
getLogger().severe("[LogBlock] Error while loading: " + ex.getMessage()); getLogger().severe("[LogBlock] Error while loading: " + ex.getMessage());
errorAtLoading = true; errorAtLoading = true;
return; return;
} }
consumer = new Consumer(this); consumer = new Consumer(this);
} }
@Override @Override
public void onEnable() { public void onEnable() {
final PluginManager pm = getPluginManager(); final PluginManager pm = getPluginManager();
if (errorAtLoading) { if (errorAtLoading) {
pm.disablePlugin(this); pm.disablePlugin(this);
return; return;
} }
if (noDb) if (noDb)
return; return;
if (pm.getPlugin("WorldEdit") == null && !new File("lib/WorldEdit.jar").exists() && !new File("WorldEdit.jar").exists()) if (pm.getPlugin("WorldEdit") == null && !new File("lib/WorldEdit.jar").exists() && !new File("WorldEdit.jar").exists())
try { try {
download(getLogger(), new URL("http://diddiz.insane-architects.net/download/WorldEdit.jar"), new File("lib/WorldEdit.jar")); 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."); getLogger().info("[LogBlock] You've to restart/reload your server now.");
pm.disablePlugin(this); pm.disablePlugin(this);
return; return;
} catch (final Exception ex) { } catch (final Exception ex) {
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."); 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.");
} }
commandsHandler = new CommandsHandler(this); commandsHandler = new CommandsHandler(this);
getCommand("lb").setExecutor(commandsHandler); getCommand("lb").setExecutor(commandsHandler);
getLogger().info("[LogBlock] Permissions plugin not found. Using Bukkit Permissions."); getLogger().info("[LogBlock] Permissions plugin not found. Using Bukkit Permissions.");
if (enableAutoClearLog && autoClearLogDelay > 0) if (enableAutoClearLog && autoClearLogDelay > 0)
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new AutoClearLog(this), 6000, autoClearLogDelay * 60 * 20); getServer().getScheduler().scheduleAsyncRepeatingTask(this, new AutoClearLog(this), 6000, autoClearLogDelay * 60 * 20);
getServer().getScheduler().scheduleAsyncDelayedTask(this, new DumpedLogImporter(this)); getServer().getScheduler().scheduleAsyncDelayedTask(this, new DumpedLogImporter(this));
registerEvents(); registerEvents();
if (useBukkitScheduler) { if (useBukkitScheduler) {
if (getServer().getScheduler().scheduleAsyncRepeatingTask(this, consumer, delayBetweenRuns * 20, delayBetweenRuns * 20) > 0) if (getServer().getScheduler().scheduleAsyncRepeatingTask(this, consumer, delayBetweenRuns * 20, delayBetweenRuns * 20) > 0)
getLogger().info("[LogBlock] Scheduled consumer with bukkit scheduler."); getLogger().info("[LogBlock] Scheduled consumer with bukkit scheduler.");
else { else {
getLogger().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 = new Timer();
timer.scheduleAtFixedRate(consumer, delayBetweenRuns * 1000, delayBetweenRuns * 1000); timer.scheduleAtFixedRate(consumer, delayBetweenRuns * 1000, delayBetweenRuns * 1000);
} }
} else { } else {
timer = new Timer(); timer = new Timer();
timer.scheduleAtFixedRate(consumer, delayBetweenRuns * 1000, delayBetweenRuns * 1000); timer.scheduleAtFixedRate(consumer, delayBetweenRuns * 1000, delayBetweenRuns * 1000);
getLogger().info("[LogBlock] Scheduled consumer with timer."); getLogger().info("[LogBlock] Scheduled consumer with timer.");
} }
for (final Tool tool : toolsByType.values()) for (final Tool tool : toolsByType.values())
if (pm.getPermission("logblock.tools." + tool.name) == null) { if (pm.getPermission("logblock.tools." + tool.name) == null) {
final Permission perm = new Permission("logblock.tools." + tool.name, tool.permissionDefault); final Permission perm = new Permission("logblock.tools." + tool.name, tool.permissionDefault);
pm.addPermission(perm); pm.addPermission(perm);
} }
// perm.addParent("logblock.*", true); // perm.addParent("logblock.*", true);
getLogger().info("LogBlock v" + getDescription().getVersion() + " by DiddiZ enabled."); getLogger().info("LogBlock v" + getDescription().getVersion() + " by DiddiZ enabled.");
} }
public void reload() { public void reload() {
// TODO // TODO
} }
private void registerEvents() { private void registerEvents() {
final PluginManager pm = getPluginManager(); final PluginManager pm = getPluginManager();
pm.registerEvents(new ToolListener(this), this); pm.registerEvents(new ToolListener(this), this);
if (askRollbackAfterBan) if (askRollbackAfterBan)
pm.registerEvents(new BanListener(this), this); pm.registerEvents(new BanListener(this), this);
if (isLogging(Logging.BLOCKPLACE)) if (isLogging(Logging.BLOCKPLACE))
pm.registerEvents(new BlockPlaceLogging(this), this); pm.registerEvents(new BlockPlaceLogging(this), this);
if (isLogging(Logging.BLOCKPLACE) || isLogging(Logging.LAVAFLOW) || isLogging(Logging.WATERFLOW)) if (isLogging(Logging.BLOCKPLACE) || isLogging(Logging.LAVAFLOW) || isLogging(Logging.WATERFLOW))
pm.registerEvents(new FluidFlowLogging(this), this); pm.registerEvents(new FluidFlowLogging(this), this);
if (isLogging(Logging.BLOCKBREAK)) if (isLogging(Logging.BLOCKBREAK))
pm.registerEvents(new BlockBreakLogging(this), this); pm.registerEvents(new BlockBreakLogging(this), this);
if (isLogging(Logging.SIGNTEXT)) if (isLogging(Logging.SIGNTEXT))
pm.registerEvents(new SignChangeLogging(this), this); pm.registerEvents(new SignChangeLogging(this), this);
if (isLogging(Logging.FIRE)) if (isLogging(Logging.FIRE))
pm.registerEvents(new BlockBurnLogging(this), this); pm.registerEvents(new BlockBurnLogging(this), this);
if (isLogging(Logging.SNOWFORM)) if (isLogging(Logging.SNOWFORM))
pm.registerEvents(new SnowFormLogging(this), this); pm.registerEvents(new SnowFormLogging(this), this);
if (isLogging(Logging.SNOWFADE)) if (isLogging(Logging.SNOWFADE))
pm.registerEvents(new SnowFadeLogging(this), this); pm.registerEvents(new SnowFadeLogging(this), this);
if (isLogging(Logging.CREEPEREXPLOSION) || isLogging(Logging.TNTEXPLOSION) || isLogging(Logging.GHASTFIREBALLEXPLOSION) || isLogging(Logging.ENDERDRAGON) || isLogging(Logging.MISCEXPLOSION)) if (isLogging(Logging.CREEPEREXPLOSION) || isLogging(Logging.TNTEXPLOSION) || isLogging(Logging.GHASTFIREBALLEXPLOSION) || isLogging(Logging.ENDERDRAGON) || isLogging(Logging.MISCEXPLOSION))
pm.registerEvents(new ExplosionLogging(this), this); pm.registerEvents(new ExplosionLogging(this), this);
if (isLogging(Logging.LEAVESDECAY)) if (isLogging(Logging.LEAVESDECAY))
pm.registerEvents(new LeavesDecayLogging(this), this); pm.registerEvents(new LeavesDecayLogging(this), this);
if (isLogging(Logging.CHESTACCESS)) { if (isLogging(Logging.CHESTACCESS)) {
pm.registerEvents(new ChestAccessLogging(this), this); pm.registerEvents(new ChestAccessLogging(this), this);
} }
if (isLogging(Logging.SWITCHINTERACT) || isLogging(Logging.DOORINTERACT) || isLogging(Logging.CAKEEAT) || isLogging(Logging.DIODEINTERACT) || isLogging(Logging.NOTEBLOCKINTERACT)) if (isLogging(Logging.SWITCHINTERACT) || isLogging(Logging.DOORINTERACT) || isLogging(Logging.CAKEEAT) || isLogging(Logging.DIODEINTERACT) || isLogging(Logging.NOTEBLOCKINTERACT))
pm.registerEvents(new InteractLogging(this), this); pm.registerEvents(new InteractLogging(this), this);
if (isLogging(Logging.KILL)) if (isLogging(Logging.KILL))
pm.registerEvents(new KillLogging(this), this); pm.registerEvents(new KillLogging(this), this);
if (isLogging(Logging.CHAT)) if (isLogging(Logging.CHAT))
pm.registerEvents(new ChatLogging(this), this); pm.registerEvents(new ChatLogging(this), this);
if (isLogging(Logging.ENDERMEN)) if (isLogging(Logging.ENDERMEN))
pm.registerEvents(new EndermenLogging(this), this); pm.registerEvents(new EndermenLogging(this), this);
if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW)) if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW))
pm.registerEvents(new StructureGrowLogging(this), this); pm.registerEvents(new StructureGrowLogging(this), this);
if (logPlayerInfo) if (logPlayerInfo)
pm.registerEvents(new PlayerInfoLogging(this), this); pm.registerEvents(new PlayerInfoLogging(this), this);
} }
@Override @Override
public void onDisable() { public void onDisable() {
if (timer != null) if (timer != null)
timer.cancel(); timer.cancel();
getServer().getScheduler().cancelTasks(this); getServer().getScheduler().cancelTasks(this);
if (consumer != null) { if (consumer != null) {
if (logPlayerInfo && getServer().getOnlinePlayers() != null) if (logPlayerInfo && getServer().getOnlinePlayers() != null)
for (final Player player : getServer().getOnlinePlayers()) for (final Player player : getServer().getOnlinePlayers())
consumer.queueLeave(player); consumer.queueLeave(player);
if (consumer.getQueueSize() > 0) { if (consumer.getQueueSize() > 0) {
getLogger().info("[LogBlock] Waiting for consumer ..."); getLogger().info("[LogBlock] Waiting for consumer ...");
int tries = 10; int tries = 10;
while (consumer.getQueueSize() > 0) { while (consumer.getQueueSize() > 0) {
getLogger().info("[LogBlock] Remaining queue size: " + consumer.getQueueSize()); getLogger().info("[LogBlock] Remaining queue size: " + consumer.getQueueSize());
if (tries > 0) if (tries > 0)
getLogger().info("[LogBlock] Remaining tries: " + tries); getLogger().info("[LogBlock] Remaining tries: " + tries);
else { else {
getLogger().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 { try {
consumer.writeToFile(); consumer.writeToFile();
getLogger().info("Successfully dumped queue."); getLogger().info("Successfully dumped queue.");
} catch (final FileNotFoundException ex) { } catch (final FileNotFoundException ex) {
getLogger().info("Failed to write. Given up."); getLogger().info("Failed to write. Given up.");
break; break;
} }
} }
consumer.run(); consumer.run();
tries--; tries--;
} }
} }
} }
if (pool != null) if (pool != null)
pool.close(); pool.close();
getLogger().info("LogBlock disabled."); getLogger().info("LogBlock disabled.");
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (noDb) if (noDb)
sender.sendMessage(ChatColor.RED + "No database connected. Check your MySQL user/pw and database for typos. Start/restart your MySQL server."); sender.sendMessage(ChatColor.RED + "No database connected. Check your MySQL user/pw and database for typos. Start/restart your MySQL server.");
return true; return true;
} }
public boolean hasPermission(CommandSender sender, String permission) { public boolean hasPermission(CommandSender sender, String permission) {
return sender.hasPermission(permission); return sender.hasPermission(permission);
} }
public Connection getConnection() { public Connection getConnection() {
try { try {
final Connection conn = pool.getConnection(); final Connection conn = pool.getConnection();
if (!connected) { if (!connected) {
getLogger().info("[LogBlock] MySQL connection rebuild"); getLogger().info("[LogBlock] MySQL connection rebuild");
connected = true; connected = true;
} }
return conn; return conn;
} catch (final Exception ex) { } catch (final Exception ex) {
if (connected) { if (connected) {
getLogger().log(Level.SEVERE, "[LogBlock] Error while fetching connection: ", ex); getLogger().log(Level.SEVERE, "[LogBlock] Error while fetching connection: ", ex);
connected = false; connected = false;
} else } else
getLogger().severe("[LogBlock] MySQL connection lost"); getLogger().severe("[LogBlock] MySQL connection lost");
return null; return null;
} }
} }
/** /**
* @param params * @param params
* QueryParams that contains the needed columns (all other will be filled with default values) and the params. World is required. * QueryParams that contains the needed columns (all other will be filled with default values) and the params. World is required.
*/ */
public List<BlockChange> getBlockChanges(QueryParams params) throws SQLException { public List<BlockChange> getBlockChanges(QueryParams params) throws SQLException {
final Connection conn = getConnection(); final Connection conn = getConnection();
Statement state = null; Statement state = null;
if (conn == null) if (conn == null)
throw new SQLException("No connection"); throw new SQLException("No connection");
try { try {
state = conn.createStatement(); state = conn.createStatement();
final ResultSet rs = state.executeQuery(params.getQuery()); final ResultSet rs = state.executeQuery(params.getQuery());
final List<BlockChange> blockchanges = new ArrayList<BlockChange>(); final List<BlockChange> blockchanges = new ArrayList<BlockChange>();
while (rs.next()) while (rs.next())
blockchanges.add(new BlockChange(rs, params)); blockchanges.add(new BlockChange(rs, params));
return blockchanges; return blockchanges;
} finally { } finally {
if (state != null) if (state != null)
state.close(); state.close();
conn.close(); conn.close();
} }
} }
public int getCount(QueryParams params) throws SQLException { public int getCount(QueryParams params) throws SQLException {
final Connection conn = getConnection(); final Connection conn = getConnection();
Statement state = null; Statement state = null;
if (conn == null) if (conn == null)
throw new SQLException("No connection"); throw new SQLException("No connection");
try { try {
state = conn.createStatement(); state = conn.createStatement();
final QueryParams p = params.clone(); final QueryParams p = params.clone();
p.needCount = true; p.needCount = true;
final ResultSet rs = state.executeQuery(p.getQuery()); final ResultSet rs = state.executeQuery(p.getQuery());
if (!rs.next()) if (!rs.next())
return 0; return 0;
return rs.getInt(1); return rs.getInt(1);
} finally { } finally {
if (state != null) if (state != null)
state.close(); state.close();
conn.close(); conn.close();
} }
} }
} }

View File

@@ -1,10 +1,13 @@
package de.diddiz.LogBlock; package de.diddiz.LogBlock;
public enum Logging { public enum Logging
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true), GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION, FIRE(true), LEAVESDECAY, LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT, SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, NATURALSTRUCTUREGROW, BONEMEALSTRUCTUREGROW; {
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true),
GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION, FIRE(true), LEAVESDECAY,
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, NATURALSTRUCTUREGROW,
BONEMEALSTRUCTUREGROW;
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() {

View File

@@ -452,7 +452,8 @@ public class QueryParams implements Cloneable
params.players = new ArrayList<String>(players); params.players = new ArrayList<String>(players);
params.types = new ArrayList<Integer>(types); params.types = new ArrayList<Integer>(types);
return params; return params;
} catch (final CloneNotSupportedException ex) {} } catch (final CloneNotSupportedException ex) {
}
return null; return null;
} }
@@ -487,15 +488,18 @@ public class QueryParams implements Cloneable
match = p.match; match = p.match;
} }
public static enum BlockChangeType { public static enum BlockChangeType
{
ALL, BOTH, CHESTACCESS, CREATED, DESTROYED, CHAT ALL, BOTH, CHESTACCESS, CREATED, DESTROYED, CHAT
} }
public static enum Order { public static enum Order
{
ASC, DESC ASC, DESC
} }
public static enum SummarizationMode { public static enum SummarizationMode
{
NONE, PLAYERS, TYPES NONE, PLAYERS, TYPES
} }
} }

View File

@@ -1,5 +1,6 @@
package de.diddiz.LogBlock; package de.diddiz.LogBlock;
public enum ToolBehavior { public enum ToolBehavior
{
TOOL, BLOCK, NONE TOOL, BLOCK, NONE
} }

View File

@@ -1,8 +1,8 @@
package de.diddiz.LogBlock; package de.diddiz.LogBlock;
public enum ToolMode { public enum ToolMode
{
CLEARLOG("logblock.clearlog"), LOOKUP("logblock.lookup"), REDO("logblock.rollback"), ROLLBACK("logblock.rollback"), WRITELOGFILE("logblock.rollback"); CLEARLOG("logblock.clearlog"), LOOKUP("logblock.lookup"), REDO("logblock.rollback"), ROLLBACK("logblock.rollback"), WRITELOGFILE("logblock.rollback");
private final String permission; private final String permission;
private ToolMode(String permission) { private ToolMode(String permission) {

View File

@@ -19,8 +19,8 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Bed; import org.bukkit.material.Bed;
import org.bukkit.material.PistonBaseMaterial; import org.bukkit.material.PistonBaseMaterial;
@@ -109,13 +109,15 @@ public class WorldEditor implements Runnable
for (final LookupCacheElement err : errorList) for (final LookupCacheElement err : errorList)
writer.println(err.getMessage()); writer.println(err.getMessage());
writer.close(); writer.close();
} catch (final Exception ex) {} } catch (final Exception ex) {
}
errors = errorList.toArray(new WorldEditorException[errorList.size()]); errors = errorList.toArray(new WorldEditorException[errorList.size()]);
notify(); notify();
} }
} }
private static enum PerformResult { private static enum PerformResult
{
SUCCESS, BLACKLISTED, NO_ACTION SUCCESS, BLACKLISTED, NO_ACTION
} }

View File

@@ -54,7 +54,8 @@ public class Config
public static Set<Integer> hiddenBlocks; public static Set<Integer> hiddenBlocks;
public static Set<String> hiddenPlayers; public static Set<String> hiddenPlayers;
public static enum LogKillsLevel { public static enum LogKillsLevel
{
PLAYERS, MONSTERS, ANIMALS; PLAYERS, MONSTERS, ANIMALS;
} }

View File

@@ -29,7 +29,8 @@ public class BanListener implements Listener
p.setPlayer(split[1].equalsIgnoreCase("g") ? split[2] : split[1]); p.setPlayer(split[1].equalsIgnoreCase("g") ? split[2] : split[1]);
p.since = 0; p.since = 0;
p.silent = false; p.silent = false;
getScheduler().scheduleAsyncDelayedTask(logblock, new Runnable() { getScheduler().scheduleAsyncDelayedTask(logblock, new Runnable()
{
@Override @Override
public void run() { public void run() {
for (final World world : logblock.getServer().getWorlds()) for (final World world : logblock.getServer().getWorlds())
@@ -37,7 +38,8 @@ public class BanListener implements Listener
p.world = world; p.world = world;
try { try {
handler.new CommandRollback(event.getPlayer(), p, false); handler.new CommandRollback(event.getPlayer(), p, false);
} catch (final Exception ex) {} } catch (final Exception ex) {
}
} }
} }
}); });

View File

@@ -1,6 +1,5 @@
package de.diddiz.LogBlock.listeners; package de.diddiz.LogBlock.listeners;
import de.diddiz.LogBlock.LogBlock;
import static de.diddiz.util.BukkitUtils.compareInventories; import static de.diddiz.util.BukkitUtils.compareInventories;
import static de.diddiz.util.BukkitUtils.compressInventory; import static de.diddiz.util.BukkitUtils.compressInventory;
import static de.diddiz.util.BukkitUtils.rawData; import static de.diddiz.util.BukkitUtils.rawData;
@@ -14,39 +13,40 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import de.diddiz.LogBlock.LogBlock;
public class ChestAccessLogging extends LoggingListener public class ChestAccessLogging extends LoggingListener
{ {
private final Map<HumanEntity, ItemStack[]> containers = new HashMap<HumanEntity, ItemStack[]>(); private final Map<HumanEntity, ItemStack[]> containers = new HashMap<HumanEntity, ItemStack[]>();
public ChestAccessLogging(LogBlock lb) { public ChestAccessLogging(LogBlock lb) {
super(lb); super(lb);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
if (event.getInventory().getHolder() instanceof BlockState) { if (event.getInventory().getHolder() instanceof BlockState) {
final HumanEntity player = event.getPlayer(); final HumanEntity player = event.getPlayer();
final ItemStack[] before = containers.get(player); final ItemStack[] before = containers.get(player);
if (before != null) { if (before != null) {
final ItemStack[] after = compressInventory(event.getInventory().getContents()); final ItemStack[] after = compressInventory(event.getInventory().getContents());
final ItemStack[] diff = compareInventories(before, after); final ItemStack[] diff = compareInventories(before, after);
final Location loc = ((BlockState) event.getInventory().getHolder()).getLocation(); final Location loc = ((BlockState)event.getInventory().getHolder()).getLocation();
for (final ItemStack item : diff) { for (final ItemStack item : diff) {
consumer.queueChestAccess(player.getName(), loc, loc.getWorld().getBlockTypeIdAt(loc), (short) item.getTypeId(), (short) item.getAmount(), rawData(item)); consumer.queueChestAccess(player.getName(), loc, loc.getWorld().getBlockTypeIdAt(loc), (short)item.getTypeId(), (short)item.getAmount(), rawData(item));
} }
containers.remove(player); containers.remove(player);
} }
} }
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) { public void onInventoryOpen(InventoryOpenEvent event) {
if (event.getInventory().getHolder() instanceof BlockState) { if (event.getInventory().getHolder() instanceof BlockState) {
BlockState block = (BlockState) event.getInventory().getHolder(); BlockState block = (BlockState)event.getInventory().getHolder();
if (block.getTypeId() != 58) { if (block.getTypeId() != 58) {
containers.put(event.getPlayer(), compressInventory(event.getInventory().getContents())); containers.put(event.getPlayer(), compressInventory(event.getInventory().getContents()));
} }
} }
} }
} }

View File

@@ -4,6 +4,7 @@ import static de.diddiz.LogBlock.Session.getSession;
import static de.diddiz.LogBlock.Session.hasSession; import static de.diddiz.LogBlock.Session.hasSession;
import static de.diddiz.LogBlock.config.Config.isLogged; import static de.diddiz.LogBlock.config.Config.isLogged;
import static de.diddiz.LogBlock.config.Config.toolsByType; import static de.diddiz.LogBlock.config.Config.toolsByType;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@@ -16,7 +17,6 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
import de.diddiz.LogBlock.CommandsHandler; import de.diddiz.LogBlock.CommandsHandler;
import de.diddiz.LogBlock.LogBlock; import de.diddiz.LogBlock.LogBlock;
import de.diddiz.LogBlock.QueryParams; import de.diddiz.LogBlock.QueryParams;

View File

@@ -13,11 +13,11 @@ import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class BukkitUtils public class BukkitUtils

View File

@@ -102,7 +102,8 @@ public class MySQLConnectionPool implements Closeable
while (true) { while (true) {
try { try {
Thread.sleep(300000); Thread.sleep(300000);
} catch (final InterruptedException e) {} } catch (final InterruptedException e) {
}
reapConnections(); reapConnections();
} }
} }
@@ -428,7 +429,8 @@ public class MySQLConnectionPool implements Closeable
void terminate() { void terminate() {
try { try {
conn.close(); conn.close();
} catch (final SQLException ex) {} } catch (final SQLException ex) {
}
} }
} }
} }

View File

@@ -59,7 +59,8 @@ public class Utils
try { try {
Integer.parseInt(str); Integer.parseInt(str);
return true; return true;
} catch (final NumberFormatException ex) {} } catch (final NumberFormatException ex) {
}
return false; return false;
} }
@@ -67,7 +68,8 @@ public class Utils
try { try {
Byte.parseByte(str); Byte.parseByte(str);
return true; return true;
} catch (final NumberFormatException ex) {} } catch (final NumberFormatException ex) {
}
return false; return false;
} }