Renamed table players to lb-players

This commit is contained in:
Robin Kupper
2011-03-11 22:12:45 +01:00
parent 86fd87444e
commit 614879d344
7 changed files with 15 additions and 15 deletions

View File

@ -38,7 +38,7 @@ public class AreaBlockSearch implements Runnable
SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss");
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement("SELECT * FROM `" + table + "` INNER JOIN `players` USING (`playerid`) WHERE (type = ? or replaced = ?) and y > ? and y < ? and x > ? and x < ? and z > ? and z < ? order by date desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT * FROM `" + table + "` INNER JOIN `lb-players` USING (`playerid`) WHERE (type = ? or replaced = ?) and y > ? and y < ? and x > ? and x < ? and z > ? and z < ? order by date desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, type);
ps.setInt(2, type);
ps.setInt(3, location.getBlockY() - size);

View File

@ -34,7 +34,7 @@ public class AreaStats implements Runnable
ResultSet rs = null;
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement("SELECT playername, count(playername) as num from `" + table + "` INNER JOIN `players` USING (`playerid`) where type > 0 and y > ? and y < ? and x > ? and x < ? and z > ? and z < ? group by playername order by count(playername) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT playername, count(playername) as num from `" + table + "` INNER JOIN `lb-players` USING (`playerid`) where type > 0 and y > ? and y < ? and x > ? and x < ? and z > ? and z < ? group by playername order by count(playername) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, player.getLocation().getBlockY()-size);
ps.setInt(2, player.getLocation().getBlockY()+size);
ps.setInt(3, player.getLocation().getBlockX()-size);
@ -48,7 +48,7 @@ public class AreaStats implements Runnable
}
rs.close();
ps.close();
ps = conn.prepareStatement("SELECT playername, count(playername) as num from `" + table + "` INNER JOIN `players` USING (`playerid`) where replaced > 0 and y > ? and y < ? and x > ? and x < ? and z > ? and z < ? group by playername order by count(playername) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT playername, count(playername) as num from `" + table + "` INNER JOIN `lb-players` USING (`playerid`) where replaced > 0 and y > ? and y < ? and x > ? and x < ? and z > ? and z < ? group by playername order by count(playername) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, player.getLocation().getBlockY()-size);
ps.setInt(2, player.getLocation().getBlockY()+size);
ps.setInt(3, player.getLocation().getBlockX()-size);

View File

@ -43,7 +43,7 @@ public class BlockStats implements Runnable
SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss");
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement("SELECT * FROM `" + table + "` LEFT JOIN `" + table + "-sign` USING (`id`) INNER JOIN `players` USING (`playerid`) WHERE `x` = ? AND `y` = ? AND `z` = ? ORDER BY `date` DESC", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT * FROM `" + table + "` LEFT JOIN `" + table + "-sign` USING (`id`) INNER JOIN `lb-players` USING (`playerid`) WHERE `x` = ? AND `y` = ? AND `z` = ? ORDER BY `date` DESC", Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, block.getX());
ps.setInt(2, block.getY());
ps.setInt(3, block.getZ());

View File

@ -263,11 +263,11 @@ public class LogBlock extends JavaPlugin
try {
DatabaseMetaData dbm = conn.getMetaData();
state = conn.createStatement();
if (!dbm.getTables(null, null, "players", null).next()) {
if (!dbm.getTables(null, null, "lb-players", null).next()) {
log.log(Level.INFO, "[LogBlock] Crating table players.");
state.execute("CREATE TABLE `players` (`playerid` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, `playername` varchar(32) NOT NULL DEFAULT '-', PRIMARY KEY (`playerid`), UNIQUE (`playername`))");
state.execute("INSERT INTO `players` (`playername`) VALUES ('environment');");
if (!dbm.getTables(null, null, "players", null).next())
state.execute("CREATE TABLE `lb-players` (`playerid` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, `playername` varchar(32) NOT NULL DEFAULT '-', PRIMARY KEY (`playerid`), UNIQUE (`playername`))");
state.execute("INSERT INTO `lb-players` (`playername`) VALUES ('environment');");
if (!dbm.getTables(null, null, "lb-players", null).next())
return false;
}
for (int i = 0; i < Config.worldNames.size(); i++) {
@ -448,7 +448,7 @@ private boolean CheckPermission(Player player, String permission) {
return;
try {
state = conn.createStatement();
state.execute("INSERT IGNORE INTO `players` (`playername`) VALUES ('" + event.getPlayer().getName() + "');");
state.execute("INSERT IGNORE INTO `lb-players` (`playername`) VALUES ('" + event.getPlayer().getName() + "');");
} catch (SQLException ex) {
log.log(Level.SEVERE, "[LogBlock] SQL exception", ex);
} finally {
@ -567,7 +567,7 @@ private boolean CheckPermission(Player player, String permission) {
b = bqueue.poll(1L, TimeUnit.SECONDS);
if (b == null)
continue;
ps = conn.prepareStatement("INSERT INTO `" + b.table + "` (`date`, `playerid`, `replaced`, `type`, `data`, `x`, `y`, `z`) SELECT now(), `playerid`, ?, ?, ?, ?, ? , ? FROM `players` WHERE `playername` = ?", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("INSERT INTO `" + b.table + "` (`date`, `playerid`, `replaced`, `type`, `data`, `x`, `y`, `z`) SELECT now(), `playerid`, ?, ?, ?, ?, ? , ? FROM `lb-players` WHERE `playername` = ?", Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, b.replaced);
ps.setInt(2, b.type);
ps.setByte(3, b.data);

View File

@ -37,7 +37,7 @@ public class PlayerAreaStats implements Runnable
ResultSet rs = null;
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement("SELECT type, count(type) as num from `" + table + "` INNER JOIN `players` USING (`playerid`) where type > 0 and playername = ? and y > 0 and x > ? and x < ? and z > ? and z < ? group by type order by count(replaced) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT type, count(type) as num from `" + table + "` INNER JOIN `lb-players` USING (`playerid`) where type > 0 and playername = ? and y > 0 and x > ? and x < ? and z > ? and z < ? group by type order by count(replaced) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps.setString(1, name);
ps.setInt(2, player.getLocation().getBlockX()-size);
ps.setInt(3, player.getLocation().getBlockX()+size);
@ -50,7 +50,7 @@ public class PlayerAreaStats implements Runnable
}
rs.close();
ps.close();
ps = conn.prepareStatement("SELECT replaced, count(replaced) as num from `" + table + "` INNER JOIN `players` USING (`playerid`) where replaced > 0 and playername = ? and y > 0 and x > ? and x < ? and z > ? and z < ? group by replaced order by count(replaced) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT replaced, count(replaced) as num from `" + table + "` INNER JOIN `lb-players` USING (`playerid`) where replaced > 0 and playername = ? and y > 0 and x > ? and x < ? and z > ? and z < ? group by replaced order by count(replaced) desc limit 10", Statement.RETURN_GENERATED_KEYS);
ps.setString(1, name);
ps.setInt(2, player.getLocation().getBlockX()-size);
ps.setInt(3, player.getLocation().getBlockX()+size);

View File

@ -26,7 +26,7 @@ public class Rollback implements Runnable
this.conn = conn;
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement("SELECT type, data, replaced, x, y, z FROM `" + table + "` INNER JOIN `players` USING (`playerid`) WHERE playername = ? AND date > date_sub(now(), INTERVAL ? MINUTE) ORDER BY date DESC", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT type, data, replaced, x, y, z FROM `" + table + "` INNER JOIN `lb-players` USING (`playerid`) WHERE playername = ? AND date > date_sub(now(), INTERVAL ? MINUTE) ORDER BY date DESC", Statement.RETURN_GENERATED_KEYS);
ps.setString(1, name);
ps.setInt(2, minutes);
} catch (SQLException ex) {
@ -41,7 +41,7 @@ public class Rollback implements Runnable
this.conn = conn;
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement("SELECT type, data, replaced, x, y, z FROM `" + table + "` WHERE y > 0 and x > ? and x < ? and z > ? and z < ? AND date > date_sub(now(), INTERVAL ? MINUTE) ORDER BY date DESC", Statement.RETURN_GENERATED_KEYS);
ps = conn.prepareStatement("SELECT type, data, replaced, x, y, z FROM `" + table + "` and x > ? and x < ? and z > ? and z < ? AND date > date_sub(now(), INTERVAL ? MINUTE) ORDER BY date DESC", Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, player.getLocation().getBlockX()-radius);
ps.setInt(2, player.getLocation().getBlockX()+radius);
ps.setInt(3, player.getLocation().getBlockZ()-radius);

View File

@ -1,5 +1,5 @@
name: LogBlock
version: 0.7
version: 0.7b
author: DiddiZ, bootswithdefer
website: http://www.diddiz.de/minecraft/
main: de.diddiz.LogBlock.LogBlock