forked from LogBlock/LogBlock
Removed static fields in Config
This commit is contained in:
@@ -20,8 +20,8 @@ public class ClearLog implements Runnable
|
|||||||
Statement state = null;
|
Statement state = null;
|
||||||
try {
|
try {
|
||||||
state = conn.createStatement();
|
state = conn.createStatement();
|
||||||
for (String table : Config.worldTables) {
|
for (String table : LogBlock.config.worldTables) {
|
||||||
int deleted = state.executeUpdate("DELETE FROM `" + table + "` WHERE date < date_sub(now(), INTERVAL " + Config.keepLogDays + " DAY)");
|
int deleted = state.executeUpdate("DELETE FROM `" + table + "` WHERE date < date_sub(now(), INTERVAL " + LogBlock.config.keepLogDays + " DAY)");
|
||||||
if (deleted > 0)
|
if (deleted > 0)
|
||||||
LogBlock.log.info("[LogBlock] Cleared out table " + table + ". Deleted " + deleted + " entries.");
|
LogBlock.log.info("[LogBlock] Cleared out table " + table + ". Deleted " + deleted + " entries.");
|
||||||
deleted = state.executeUpdate("DELETE `" + table + "-sign` FROM `" + table + "-sign` LEFT JOIN `" + table + "` ON (`" + table + "-sign`.`id` = `" + table + "`.`id`) WHERE `" + table + "`.`id` IS NULL;");
|
deleted = state.executeUpdate("DELETE `" + table + "-sign` FROM `" + table + "-sign` LEFT JOIN `" + table + "` ON (`" + table + "-sign`.`id` = `" + table + "`.`id`) WHERE `" + table + "`.`id` IS NULL;");
|
||||||
|
@@ -6,31 +6,31 @@ import java.util.List;
|
|||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
static List<String> worldNames;
|
List<String> worldNames;
|
||||||
static List<String> worldTables;
|
List<String> worldTables;
|
||||||
static String dbDriver;
|
String dbDriver;
|
||||||
static String dbUrl;
|
String dbUrl;
|
||||||
static String dbUsername;
|
String dbUsername;
|
||||||
static String dbPassword;
|
String dbPassword;
|
||||||
static int keepLogDays;
|
int keepLogDays;
|
||||||
static int delay;
|
int delay;
|
||||||
static int defaultDist;
|
int defaultDist;
|
||||||
static int defaultTime;
|
int defaultTime;
|
||||||
static int toolID;
|
int toolID;
|
||||||
static int toolblockID;
|
int toolblockID;
|
||||||
static boolean toolblockRemove;
|
boolean toolblockRemove;
|
||||||
static boolean logSignTexts;
|
boolean logSignTexts;
|
||||||
static boolean logExplosions;
|
boolean logExplosions;
|
||||||
static boolean logFire;
|
boolean logFire;
|
||||||
static boolean logLeavesDecay;
|
boolean logLeavesDecay;
|
||||||
static boolean logChestAccess;
|
boolean logChestAccess;
|
||||||
static String logTNTExplosionsAs;
|
String logTNTExplosionsAs;
|
||||||
static String logCreeperExplosionsAs;
|
String logCreeperExplosionsAs;
|
||||||
static String logFireAs;
|
String logFireAs;
|
||||||
static String logLeavesDecayAs;
|
String logLeavesDecayAs;
|
||||||
static boolean usePermissions;
|
boolean usePermissions;
|
||||||
|
|
||||||
static boolean Load(Configuration config) {
|
Config (Configuration config) {
|
||||||
config.load();
|
config.load();
|
||||||
List<String> keys = config.getKeys(null);
|
List<String> keys = config.getKeys(null);
|
||||||
if (!keys.contains("worldNames"))
|
if (!keys.contains("worldNames"))
|
||||||
@@ -79,10 +79,8 @@ public class Config {
|
|||||||
config.setProperty("logLeavesDecayAs", "LeavesDecay");
|
config.setProperty("logLeavesDecayAs", "LeavesDecay");
|
||||||
if (!keys.contains("usePermissions"))
|
if (!keys.contains("usePermissions"))
|
||||||
config.setProperty("usePermissions", false);
|
config.setProperty("usePermissions", false);
|
||||||
if (!config.save()){
|
if (!config.save())
|
||||||
LogBlock.log.severe("[LogBlock] Error while writing to config.yml");
|
LogBlock.log.severe("[LogBlock] Error while writing to config.yml");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
worldNames = config.getStringList("worldNames", null);
|
worldNames = config.getStringList("worldNames", null);
|
||||||
worldTables = config.getStringList("worldTables", null);
|
worldTables = config.getStringList("worldTables", null);
|
||||||
dbDriver = config.getString("driver");
|
dbDriver = config.getString("driver");
|
||||||
@@ -106,6 +104,5 @@ public class Config {
|
|||||||
logFireAs = config.getString("logFireAs");
|
logFireAs = config.getString("logFireAs");
|
||||||
logLeavesDecayAs = config.getString("logLeavesDecayAs");
|
logLeavesDecayAs = config.getString("logLeavesDecayAs");
|
||||||
usePermissions = config.getBoolean("usePermissions", false);
|
usePermissions = config.getBoolean("usePermissions", false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ import com.sk89q.worldedit.bukkit.selections.Selection;
|
|||||||
public class LogBlock extends JavaPlugin
|
public class LogBlock extends JavaPlugin
|
||||||
{
|
{
|
||||||
static Logger log;
|
static Logger log;
|
||||||
|
static Config config;
|
||||||
private Consumer consumer = null;
|
private Consumer consumer = null;
|
||||||
private LinkedBlockingQueue<BlockRow> bqueue = new LinkedBlockingQueue<BlockRow>();
|
private LinkedBlockingQueue<BlockRow> bqueue = new LinkedBlockingQueue<BlockRow>();
|
||||||
|
|
||||||
@@ -54,16 +55,16 @@ public class LogBlock extends JavaPlugin
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
log = getServer().getLogger();
|
log = getServer().getLogger();
|
||||||
try {
|
try {
|
||||||
Config.Load(getConfiguration());
|
config = new Config(getConfiguration());
|
||||||
if (Config.usePermissions) {
|
if (config.usePermissions) {
|
||||||
if (getServer().getPluginManager().getPlugin("Permissions") != null)
|
if (getServer().getPluginManager().getPlugin("Permissions") != null)
|
||||||
log.info("[LogBlock] Permissions enabled");
|
log.info("[LogBlock] Permissions enabled");
|
||||||
else {
|
else {
|
||||||
Config.usePermissions = false;
|
config.usePermissions = false;
|
||||||
log.warning("[LogBlock] Permissions plugin not found. Using default permissions.");
|
log.warning("[LogBlock] Permissions plugin not found. Using default permissions.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new JDCConnectionDriver(Config.dbDriver, Config.dbUrl, Config.dbUsername, Config.dbPassword);
|
new JDCConnectionDriver(config.dbDriver, config.dbUrl, config.dbUsername, config.dbPassword);
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -71,7 +72,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Config.worldNames == null || Config.worldTables == null || Config.worldNames.size() == 0 || Config.worldNames.size() != Config.worldTables.size()) {
|
if (config.worldNames == null || config.worldTables == null || config.worldNames.size() == 0 || config.worldNames.size() != config.worldTables.size()) {
|
||||||
log.log(Level.SEVERE, "[LogBlock] worldNames or worldTables not set porperly");
|
log.log(Level.SEVERE, "[LogBlock] worldNames or worldTables not set porperly");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
@@ -81,7 +82,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Config.keepLogDays >= 0)
|
if (config.keepLogDays >= 0)
|
||||||
new Thread(new ClearLog(getConnection())).start();
|
new Thread(new ClearLog(getConnection())).start();
|
||||||
LBBlockListener lbBlockListener = new LBBlockListener();
|
LBBlockListener lbBlockListener = new LBBlockListener();
|
||||||
LBPlayerListener lbPlayerListener = new LBPlayerListener();
|
LBPlayerListener lbPlayerListener = new LBPlayerListener();
|
||||||
@@ -92,13 +93,13 @@ public class LogBlock extends JavaPlugin
|
|||||||
pm.registerEvent(Type.BLOCK_PLACED, lbBlockListener, Event.Priority.Monitor, this);
|
pm.registerEvent(Type.BLOCK_PLACED, lbBlockListener, Event.Priority.Monitor, this);
|
||||||
pm.registerEvent(Type.BLOCK_BREAK, lbBlockListener, Event.Priority.Monitor, this);
|
pm.registerEvent(Type.BLOCK_BREAK, lbBlockListener, Event.Priority.Monitor, this);
|
||||||
pm.registerEvent(Type.SIGN_CHANGE, lbBlockListener, Event.Priority.Monitor, this);
|
pm.registerEvent(Type.SIGN_CHANGE, lbBlockListener, Event.Priority.Monitor, this);
|
||||||
if (Config.logFire)
|
if (config.logFire)
|
||||||
pm.registerEvent(Type.BLOCK_BURN, lbBlockListener, Event.Priority.Monitor, this);
|
pm.registerEvent(Type.BLOCK_BURN, lbBlockListener, Event.Priority.Monitor, this);
|
||||||
if (Config.logExplosions)
|
if (config.logExplosions)
|
||||||
pm.registerEvent(Type.ENTITY_EXPLODE, new LBEntityListener(), Event.Priority.Monitor, this);
|
pm.registerEvent(Type.ENTITY_EXPLODE, new LBEntityListener(), Event.Priority.Monitor, this);
|
||||||
if (Config.logChestAccess)
|
if (config.logChestAccess)
|
||||||
pm.registerEvent(Type.BLOCK_INTERACT, lbBlockListener, Event.Priority.Monitor, this);
|
pm.registerEvent(Type.BLOCK_INTERACT, lbBlockListener, Event.Priority.Monitor, this);
|
||||||
if (Config.logLeavesDecay)
|
if (config.logLeavesDecay)
|
||||||
pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Event.Priority.Monitor, this);
|
pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Event.Priority.Monitor, this);
|
||||||
consumer = new Consumer();
|
consumer = new Consumer();
|
||||||
new Thread(consumer).start();
|
new Thread(consumer).start();
|
||||||
@@ -137,7 +138,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Type /lb help for help");
|
player.sendMessage(ChatColor.LIGHT_PURPLE + "Type /lb help for help");
|
||||||
} else if (args[0].equalsIgnoreCase("area")) {
|
} else if (args[0].equalsIgnoreCase("area")) {
|
||||||
if (CheckPermission(player,"logblock.area")) {
|
if (CheckPermission(player,"logblock.area")) {
|
||||||
int radius = Config.defaultDist;
|
int radius = config.defaultDist;
|
||||||
if (args.length == 2 && isInt(args[1]))
|
if (args.length == 2 && isInt(args[1]))
|
||||||
radius = Integer.parseInt(args[1]);
|
radius = Integer.parseInt(args[1]);
|
||||||
new Thread(new AreaStats(conn, player, radius, table)).start();
|
new Thread(new AreaStats(conn, player, radius, table)).start();
|
||||||
@@ -151,7 +152,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
} else if (args[0].equalsIgnoreCase("player")) {
|
} else if (args[0].equalsIgnoreCase("player")) {
|
||||||
if (CheckPermission(player,"logblock.area")) {
|
if (CheckPermission(player,"logblock.area")) {
|
||||||
if (args.length == 2 || args.length == 3) {
|
if (args.length == 2 || args.length == 3) {
|
||||||
int radius = Config.defaultDist;
|
int radius = config.defaultDist;
|
||||||
if (args.length == 3 && isInt(args[2]))
|
if (args.length == 3 && isInt(args[2]))
|
||||||
radius = Integer.parseInt(args[2]);
|
radius = Integer.parseInt(args[2]);
|
||||||
new Thread(new PlayerAreaStats(conn, player, args[1], radius, table)).start();
|
new Thread(new PlayerAreaStats(conn, player, args[1], radius, table)).start();
|
||||||
@@ -163,7 +164,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
if (CheckPermission(player,"logblock.area")) {
|
if (CheckPermission(player,"logblock.area")) {
|
||||||
if (args.length == 2 || args.length == 3) {
|
if (args.length == 2 || args.length == 3) {
|
||||||
Material mat = Material.matchMaterial(args[1]);
|
Material mat = Material.matchMaterial(args[1]);
|
||||||
int radius = Config.defaultDist;
|
int radius = config.defaultDist;
|
||||||
if (args.length == 3 && isInt(args[2]))
|
if (args.length == 3 && isInt(args[2]))
|
||||||
radius = Integer.parseInt(args[2]);
|
radius = Integer.parseInt(args[2]);
|
||||||
if (mat != null)
|
if (mat != null)
|
||||||
@@ -177,7 +178,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
} else if (args[0].equalsIgnoreCase("rollback")) {
|
} else if (args[0].equalsIgnoreCase("rollback")) {
|
||||||
if (CheckPermission(player,"logblock.rollback")) {
|
if (CheckPermission(player,"logblock.rollback")) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
int minutes = Config.defaultTime;
|
int minutes = config.defaultTime;
|
||||||
if (args[1].equalsIgnoreCase("player")) {
|
if (args[1].equalsIgnoreCase("player")) {
|
||||||
if (args.length == 3 || args.length == 5) {
|
if (args.length == 3 || args.length == 5) {
|
||||||
if (args.length == 5)
|
if (args.length == 5)
|
||||||
@@ -289,9 +290,9 @@ public class LogBlock extends JavaPlugin
|
|||||||
if (!dbm.getTables(null, null, "lb-players", null).next())
|
if (!dbm.getTables(null, null, "lb-players", null).next())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
state.execute("INSERT IGNORE INTO `lb-players` (`playername`) VALUES ('" + Config.logTNTExplosionsAs + "'), ('" + Config.logCreeperExplosionsAs + "'), ('" + Config.logFireAs + "'), ('" + Config.logLeavesDecayAs + "')");
|
state.execute("INSERT IGNORE INTO `lb-players` (`playername`) VALUES ('" + config.logTNTExplosionsAs + "'), ('" + config.logCreeperExplosionsAs + "'), ('" + config.logFireAs + "'), ('" + config.logLeavesDecayAs + "')");
|
||||||
for (int i = 0; i < Config.worldNames.size(); i++) {
|
for (int i = 0; i < config.worldNames.size(); i++) {
|
||||||
String table = Config.worldTables.get(i);
|
String table = config.worldTables.get(i);
|
||||||
if (!dbm.getTables(null, null, table, null).next()) {
|
if (!dbm.getTables(null, null, table, null).next()) {
|
||||||
log.log(Level.INFO, "[LogBlock] Crating table " + table + ".");
|
log.log(Level.INFO, "[LogBlock] Crating table " + table + ".");
|
||||||
state.execute("CREATE TABLE `" + table + "` (`id` INT NOT NULL AUTO_INCREMENT, `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `playerid` SMALLINT UNSIGNED NOT NULL DEFAULT '0', `replaced` TINYINT UNSIGNED NOT NULL DEFAULT '0', `type` TINYINT UNSIGNED NOT NULL DEFAULT '0', `data` TINYINT UNSIGNED NOT NULL DEFAULT '0', `x` SMALLINT NOT NULL DEFAULT '0', `y` TINYINT UNSIGNED NOT NULL DEFAULT '0',`z` SMALLINT NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `coords` (`y`,`x`,`z`), KEY `type` (`type`), KEY `data` (`data`), KEY `replaced` (`replaced`));");
|
state.execute("CREATE TABLE `" + table + "` (`id` INT NOT NULL AUTO_INCREMENT, `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `playerid` SMALLINT UNSIGNED NOT NULL DEFAULT '0', `replaced` TINYINT UNSIGNED NOT NULL DEFAULT '0', `type` TINYINT UNSIGNED NOT NULL DEFAULT '0', `data` TINYINT UNSIGNED NOT NULL DEFAULT '0', `x` SMALLINT NOT NULL DEFAULT '0', `y` TINYINT UNSIGNED NOT NULL DEFAULT '0',`z` SMALLINT NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `coords` (`y`,`x`,`z`), KEY `type` (`type`), KEY `data` (`data`), KEY `replaced` (`replaced`));");
|
||||||
@@ -336,10 +337,10 @@ public class LogBlock extends JavaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getTable (String worldName) {
|
private String getTable (String worldName) {
|
||||||
int idx = Config.worldNames.indexOf(worldName);
|
int idx = config.worldNames.indexOf(worldName);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return null;
|
return null;
|
||||||
return Config.worldTables.get(idx);
|
return config.worldTables.get(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void queueBlock(Player player, Block block, int typeAfter) {
|
private void queueBlock(Player player, Block block, int typeAfter) {
|
||||||
@@ -372,7 +373,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean CheckPermission(Player player, String permission) {
|
private boolean CheckPermission(Player player, String permission) {
|
||||||
if (Config.usePermissions)
|
if (config.usePermissions)
|
||||||
return Permissions.Security.permission(player, permission);
|
return Permissions.Security.permission(player, permission);
|
||||||
else {
|
else {
|
||||||
if (permission.equals("logblock.lookup"))
|
if (permission.equals("logblock.lookup"))
|
||||||
@@ -439,9 +440,9 @@ public class LogBlock extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerJoin(PlayerEvent event) {
|
public void onPlayerJoin(PlayerEvent event) {
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
Statement state = null;
|
Statement state = null;
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
@@ -459,21 +460,21 @@ public class LogBlock extends JavaPlugin
|
|||||||
log.log(Level.SEVERE, "[LogBlock] SQL exception on close", ex);
|
log.log(Level.SEVERE, "[LogBlock] SQL exception on close", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LBBlockListener extends BlockListener
|
private class LBBlockListener extends BlockListener
|
||||||
{
|
{
|
||||||
public void onBlockRightClick(BlockRightClickEvent event) {
|
public void onBlockRightClick(BlockRightClickEvent event) {
|
||||||
if (event.getItemInHand().getTypeId()== Config.toolID && CheckPermission(event.getPlayer(), "logblock.lookup"))
|
if (event.getItemInHand().getTypeId()== config.toolID && CheckPermission(event.getPlayer(), "logblock.lookup"))
|
||||||
new Thread(new BlockStats(getConnection(), event.getPlayer(), event.getBlock(), getTable(event.getBlock()))).start();
|
new Thread(new BlockStats(getConnection(), event.getPlayer(), event.getBlock(), getTable(event.getBlock()))).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
if (event.getItemInHand().getTypeId() == Config.toolblockID && CheckPermission(event.getPlayer(), "logblock.lookup")) {
|
if (event.getItemInHand().getTypeId() == config.toolblockID && CheckPermission(event.getPlayer(), "logblock.lookup")) {
|
||||||
new Thread(new BlockStats(getConnection(), event.getPlayer(), event.getBlock(), getTable(event.getBlock()))).start();
|
new Thread(new BlockStats(getConnection(), event.getPlayer(), event.getBlock(), getTable(event.getBlock()))).start();
|
||||||
if (Config.toolblockRemove)
|
if (config.toolblockRemove)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else
|
} else
|
||||||
queueBlock(event.getPlayer().getName(), event.getBlockPlaced(), event.getBlockReplacedState().getTypeId(), event.getBlockPlaced().getTypeId(), event.getBlockPlaced().getData());
|
queueBlock(event.getPlayer().getName(), event.getBlockPlaced(), event.getBlockReplacedState().getTypeId(), event.getBlockPlaced().getTypeId(), event.getBlockPlaced().getData());
|
||||||
@@ -487,7 +488,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
|
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
if (!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
if (Config.logSignTexts)
|
if (config.logSignTexts)
|
||||||
queueBlock(event.getPlayer().getName(), event.getBlock(), 0, event.getBlock().getTypeId(), event.getBlock().getData(), "sign [" + event.getLine(0) + "] [" + event.getLine(1) + "] [" + event.getLine(2) + "] [" + event.getLine(3) + "]", null);
|
queueBlock(event.getPlayer().getName(), event.getBlock(), 0, event.getBlock().getTypeId(), event.getBlock().getData(), "sign [" + event.getLine(0) + "] [" + event.getLine(1) + "] [" + event.getLine(2) + "] [" + event.getLine(3) + "]", null);
|
||||||
else
|
else
|
||||||
queueBlock(event.getPlayer().getName(), event.getBlock(), 0, event.getBlock().getTypeId(), event.getBlock().getData());
|
queueBlock(event.getPlayer().getName(), event.getBlock(), 0, event.getBlock().getTypeId(), event.getBlock().getData());
|
||||||
@@ -495,22 +496,22 @@ public class LogBlock extends JavaPlugin
|
|||||||
|
|
||||||
public void onBlockBurn(BlockBurnEvent event) {
|
public void onBlockBurn(BlockBurnEvent event) {
|
||||||
if (!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
queueBlock(Config.logFireAs, event.getBlock(), event.getBlock().getTypeId(), 0, event.getBlock().getData());
|
queueBlock(config.logFireAs, event.getBlock(), event.getBlock().getTypeId(), 0, event.getBlock().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockInteract(BlockInteractEvent event) {
|
public void onBlockInteract(BlockInteractEvent event) {
|
||||||
if (!event.isCancelled() && event.isPlayer() && event.getBlock().getType() == Material.CHEST) {
|
if (!event.isCancelled() && event.isPlayer() && event.getBlock().getType() == Material.CHEST) {
|
||||||
if (((Player)event.getEntity()).getItemInHand().getTypeId() == Config.toolID)
|
if (((Player)event.getEntity()).getItemInHand().getTypeId() == config.toolID)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
else
|
else
|
||||||
queueBlock((Player)event.getEntity(), event.getBlock(), (short)0, (byte)0, (short)0, (byte)0);
|
queueBlock((Player)event.getEntity(), event.getBlock(), (short)0, (byte)0, (short)0, (byte)0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||||
if (!event.isCancelled())
|
if (!event.isCancelled())
|
||||||
queueBlock(Config.logLeavesDecayAs, event.getBlock(), event.getBlock().getTypeId(), 0, event.getBlock().getData());
|
queueBlock(config.logLeavesDecayAs, event.getBlock(), event.getBlock().getTypeId(), 0, event.getBlock().getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LBEntityListener extends EntityListener
|
private class LBEntityListener extends EntityListener
|
||||||
@@ -519,9 +520,9 @@ public class LogBlock extends JavaPlugin
|
|||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
String name;
|
String name;
|
||||||
if (event.getEntity() == null)
|
if (event.getEntity() == null)
|
||||||
name = Config.logTNTExplosionsAs;
|
name = config.logTNTExplosionsAs;
|
||||||
else
|
else
|
||||||
name = Config.logCreeperExplosionsAs;
|
name = config.logCreeperExplosionsAs;
|
||||||
for (Block block : event.blockList())
|
for (Block block : event.blockList())
|
||||||
queueBlock(name, block, block.getTypeId(), 0, block.getData());
|
queueBlock(name, block, block.getTypeId(), 0, block.getData());
|
||||||
}
|
}
|
||||||
@@ -561,7 +562,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
try {
|
try {
|
||||||
conn = getConnection();
|
conn = getConnection();
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
while (count < 100 && start+Config.delay > (System.currentTimeMillis()/1000L)) {
|
while (count < 100 && start + config.delay > (System.currentTimeMillis()/1000L)) {
|
||||||
b = bqueue.poll(1L, TimeUnit.SECONDS);
|
b = bqueue.poll(1L, TimeUnit.SECONDS);
|
||||||
if (b == null)
|
if (b == null)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user