forked from LogBlock/LogBlock
Changed accessibility of some classes and methods.
This commit is contained in:
@@ -316,7 +316,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
public class CommandLookup extends LBCommand
|
||||
{
|
||||
CommandLookup(CommandSender sender, QueryParams params) throws Exception {
|
||||
public CommandLookup(CommandSender sender, QueryParams params) throws Exception {
|
||||
super(sender, params);
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
public class CommandSaveQueue extends LBCommand
|
||||
{
|
||||
CommandSaveQueue(CommandSender sender, QueryParams params) throws Exception {
|
||||
public CommandSaveQueue(CommandSender sender, QueryParams params) throws Exception {
|
||||
super(sender, params);
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
public class CommandTeleport extends LBCommand
|
||||
{
|
||||
CommandTeleport(CommandSender sender, QueryParams params) throws Exception {
|
||||
public CommandTeleport(CommandSender sender, QueryParams params) throws Exception {
|
||||
super(sender, params);
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
public class CommandRollback extends LBCommand
|
||||
{
|
||||
CommandRollback(CommandSender sender, QueryParams params) throws Exception {
|
||||
public CommandRollback(CommandSender sender, QueryParams params) throws Exception {
|
||||
super(sender, params);
|
||||
}
|
||||
|
||||
@@ -441,11 +441,10 @@ public class CommandsHandler implements CommandExecutor
|
||||
sender.sendMessage(ChatColor.RED + "Rollback aborted");
|
||||
return;
|
||||
}
|
||||
final long start = System.currentTimeMillis();
|
||||
editor.start();
|
||||
sender.sendMessage(ChatColor.GREEN + "Rollback finished successfully");
|
||||
sender.sendMessage(ChatColor.GREEN + "Undid " + editor.getSuccesses() + " of " + changes + " changes (" + editor.getErrors() + " errors, " + editor.getBlacklistCollisions() + " blacklist collisions)");
|
||||
sender.sendMessage(ChatColor.GREEN + "Took: " + (System.currentTimeMillis() - start) + "ms");
|
||||
sender.sendMessage(ChatColor.GREEN + "Took: " + editor.getElapsedTime() + "ms");
|
||||
} catch (final SQLException ex) {
|
||||
sender.sendMessage(ChatColor.RED + "SQL exception");
|
||||
log.log(Level.SEVERE, "[LogBlock Rollback] SQL exception", ex);
|
||||
@@ -463,7 +462,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
public class CommandRedo extends LBCommand
|
||||
{
|
||||
CommandRedo(CommandSender sender, QueryParams params) throws Exception {
|
||||
public CommandRedo(CommandSender sender, QueryParams params) throws Exception {
|
||||
super(sender, params);
|
||||
}
|
||||
|
||||
@@ -481,11 +480,10 @@ public class CommandsHandler implements CommandExecutor
|
||||
sender.sendMessage(ChatColor.RED + "Redo aborted");
|
||||
return;
|
||||
}
|
||||
final long start = System.currentTimeMillis();
|
||||
editor.start();
|
||||
sender.sendMessage(ChatColor.GREEN + "Redo finished successfully");
|
||||
sender.sendMessage(ChatColor.GREEN + "Redid " + editor.getSuccesses() + " of " + changes + " changes (" + editor.getErrors() + " errors, " + editor.getBlacklistCollisions() + " blacklist collisions)");
|
||||
sender.sendMessage(ChatColor.GREEN + "Took: " + (System.currentTimeMillis() - start) + "ms");
|
||||
sender.sendMessage(ChatColor.GREEN + "Took: " + editor.getElapsedTime() + "ms");
|
||||
} catch (final SQLException ex) {
|
||||
sender.sendMessage(ChatColor.RED + "SQL exception");
|
||||
log.log(Level.SEVERE, "[LogBlock Redo] SQL exception", ex);
|
||||
@@ -503,7 +501,7 @@ public class CommandsHandler implements CommandExecutor
|
||||
|
||||
public class CommandClearLog extends LBCommand
|
||||
{
|
||||
CommandClearLog(CommandSender sender, QueryParams params) throws Exception {
|
||||
public CommandClearLog(CommandSender sender, QueryParams params) throws Exception {
|
||||
super(sender, params);
|
||||
}
|
||||
|
||||
|
@@ -144,12 +144,21 @@ public class Consumer extends TimerTask
|
||||
queueBlock(playerName, loc, type, type, (byte)0, null, new ChestAccess(itemType, itemAmount, itemData));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a container block break. The block type before is assumed to be o (air). All content is assumed to be taken.
|
||||
*
|
||||
* @param container
|
||||
* Must be instanceof ContainerBlock
|
||||
*/
|
||||
public void queueContainerBreak(String playerName, BlockState container) {
|
||||
if (!(container instanceof ContainerBlock))
|
||||
return;
|
||||
queueContainerBreak(playerName, new Location(container.getWorld(), container.getX(), container.getY(), container.getZ()), container.getTypeId(), container.getRawData(), ((ContainerBlock)container).getInventory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a container block break. The block type before is assumed to be o (air). All content is assumed to be taken.
|
||||
*/
|
||||
public void queueContainerBreak(String playerName, Location loc, int type, byte data, Inventory inv) {
|
||||
final ItemStack[] items = BukkitUtils.compressInventory(inv.getContents());
|
||||
for (final ItemStack item : items)
|
||||
@@ -382,13 +391,13 @@ public class Consumer extends TimerTask
|
||||
|
||||
private static class BlockRow
|
||||
{
|
||||
public final ChestAccess ca;
|
||||
public final byte data;
|
||||
public final String name;
|
||||
public final int replaced, type;
|
||||
public final String signtext;
|
||||
public final int worldHash;
|
||||
public final int x, y, z;
|
||||
final ChestAccess ca;
|
||||
final byte data;
|
||||
final String name;
|
||||
final int replaced, type;
|
||||
final String signtext;
|
||||
final int worldHash;
|
||||
final int x, y, z;
|
||||
|
||||
BlockRow(int worldHash, String name, int replaced, int type, byte data, int x, int y, int z, String signtext, ChestAccess ca) {
|
||||
this.worldHash = worldHash;
|
||||
@@ -406,8 +415,8 @@ public class Consumer extends TimerTask
|
||||
|
||||
private static class ChestAccess
|
||||
{
|
||||
public final byte itemData;
|
||||
public final short itemType, itemAmount;
|
||||
final byte itemData;
|
||||
final short itemType, itemAmount;
|
||||
|
||||
ChestAccess(short itemType, short itemAmount, byte itemData) {
|
||||
this.itemType = itemType;
|
||||
@@ -418,10 +427,10 @@ public class Consumer extends TimerTask
|
||||
|
||||
private static class KillRow
|
||||
{
|
||||
public final String killer;
|
||||
public final String victim;
|
||||
public final int weapon;
|
||||
public final int worldHash;
|
||||
final String killer;
|
||||
final String victim;
|
||||
final int weapon;
|
||||
final int worldHash;
|
||||
|
||||
KillRow(int worldHash, String attacker, String defender, int weapon) {
|
||||
this.worldHash = worldHash;
|
||||
|
@@ -20,19 +20,16 @@ import de.diddiz.util.Utils;
|
||||
public class QueryParams implements Cloneable
|
||||
{
|
||||
private static final HashSet<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode()));
|
||||
BlockChangeType bct = BlockChangeType.BOTH;
|
||||
int limit = 15;
|
||||
Location loc = null;
|
||||
int minutes = 0;
|
||||
Order order = Order.DESC;
|
||||
List<String> players = new ArrayList<String>();
|
||||
boolean prepareToolQuery = false;
|
||||
int radius = -1;
|
||||
Selection sel = null;
|
||||
boolean selectFullBlockData = false;
|
||||
SummarizationMode sum = SummarizationMode.NONE;
|
||||
List<Integer> types = new ArrayList<Integer>();
|
||||
World world = null;
|
||||
public BlockChangeType bct = BlockChangeType.BOTH;
|
||||
public int limit = 15, minutes = 0, radius = -1;
|
||||
public Location loc = null;
|
||||
public Order order = Order.DESC;
|
||||
public List<String> players = new ArrayList<String>();
|
||||
public boolean prepareToolQuery = false, selectFullBlockData = false;
|
||||
public Selection sel = null;
|
||||
public SummarizationMode sum = SummarizationMode.NONE;
|
||||
public List<Integer> types = new ArrayList<Integer>();
|
||||
public World world = null;
|
||||
private final LogBlock logblock;
|
||||
|
||||
public QueryParams(LogBlock logblock) {
|
||||
@@ -44,7 +41,7 @@ public class QueryParams implements Cloneable
|
||||
parseArgs(sender, args);
|
||||
}
|
||||
|
||||
static boolean isKeyWord(String param) {
|
||||
public static boolean isKeyWord(String param) {
|
||||
if (keywords.contains(param.toLowerCase().hashCode()))
|
||||
return true;
|
||||
return false;
|
||||
@@ -119,7 +116,7 @@ public class QueryParams implements Cloneable
|
||||
title.append("at " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ() + " ");
|
||||
else if (sel != null)
|
||||
title.append("inside selection ");
|
||||
title.append("in " + getfriendlyWorldname());
|
||||
title.append("in " + BukkitUtils.friendlyWorldname(world.getName()));
|
||||
title.setCharAt(0, String.valueOf(title.charAt(0)).toUpperCase().toCharArray()[0]);
|
||||
return title.toString();
|
||||
}
|
||||
@@ -358,13 +355,7 @@ public class QueryParams implements Cloneable
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getfriendlyWorldname() {
|
||||
String worldName = world.getName();
|
||||
worldName = worldName.substring(worldName.lastIndexOf('/') + 1);
|
||||
return worldName.substring(worldName.lastIndexOf('\\') + 1);
|
||||
}
|
||||
|
||||
private String[] getValues(List<String> args, int offset) {
|
||||
private static String[] getValues(List<String> args, int offset) {
|
||||
int i;
|
||||
for (i = offset; i < args.size(); i++)
|
||||
if (isKeyWord(args.get(i)))
|
||||
@@ -377,7 +368,7 @@ public class QueryParams implements Cloneable
|
||||
return values;
|
||||
}
|
||||
|
||||
private void merge(QueryParams params) {
|
||||
public void merge(QueryParams params) {
|
||||
players = params.players;
|
||||
types = params.types;
|
||||
loc = params.loc;
|
||||
|
@@ -15,53 +15,48 @@ import de.diddiz.util.BukkitUtils;
|
||||
|
||||
public class WorldEditor implements Runnable
|
||||
{
|
||||
public static class WorldEditorException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 7509084196124728986L;
|
||||
|
||||
public WorldEditorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private final Logger log;
|
||||
private final LogBlock logblock;
|
||||
private final Config config;
|
||||
private final LinkedBlockingQueue<Edit> edits = new LinkedBlockingQueue<Edit>();
|
||||
private final World world;
|
||||
private int taskID;
|
||||
private int successes = 0;
|
||||
private int errors = 0;
|
||||
private int blacklistCollisions = 0;
|
||||
private int successes = 0, errors = 0, blacklistCollisions = 0;
|
||||
private long elapsedTime = 0;
|
||||
|
||||
WorldEditor(LogBlock logblock, World world) {
|
||||
public WorldEditor(LogBlock logblock, World world) {
|
||||
log = logblock.getServer().getLogger();
|
||||
this.logblock = logblock;
|
||||
config = logblock.getConfig();
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
int getSize() {
|
||||
public int getSize() {
|
||||
return edits.size();
|
||||
}
|
||||
|
||||
int getSuccesses() {
|
||||
public int getSuccesses() {
|
||||
return successes;
|
||||
}
|
||||
|
||||
int getErrors() {
|
||||
public int getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
int getBlacklistCollisions() {
|
||||
public int getBlacklistCollisions() {
|
||||
return blacklistCollisions;
|
||||
}
|
||||
|
||||
void queueBlockChange(int type, int replaced, byte data, int x, int y, int z, String signtext, short itemType, short itemAmount, byte itemData) {
|
||||
public void queueBlockChange(int type, int replaced, byte data, int x, int y, int z, String signtext, short itemType, short itemAmount, byte itemData) {
|
||||
edits.add(new Edit(type, replaced, data, x, y, z, signtext, itemType, itemAmount, itemData));
|
||||
}
|
||||
|
||||
synchronized void start() throws WorldEditorException {
|
||||
public long getElapsedTime() {
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
synchronized public void start() throws WorldEditorException {
|
||||
final long start = System.currentTimeMillis();
|
||||
taskID = logblock.getServer().getScheduler().scheduleSyncRepeatingTask(logblock, this, 0, 1);
|
||||
if (taskID == -1)
|
||||
throw new WorldEditorException("Failed to schedule task");
|
||||
@@ -70,6 +65,7 @@ public class WorldEditor implements Runnable
|
||||
} catch (final InterruptedException ex) {
|
||||
throw new WorldEditorException("Interrupted");
|
||||
}
|
||||
elapsedTime = System.currentTimeMillis() - start;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,8 +117,7 @@ public class WorldEditor implements Runnable
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
// TODO Fix doors and beds
|
||||
private PerformResult perform() {
|
||||
PerformResult perform() {
|
||||
if (config.dontRollback.contains(replaced))
|
||||
return PerformResult.BLACKLISTED;
|
||||
try {
|
||||
@@ -195,4 +190,13 @@ public class WorldEditor implements Runnable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class WorldEditorException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 7509084196124728986L;
|
||||
|
||||
public WorldEditorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -97,6 +97,11 @@ public class BukkitUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String friendlyWorldname(String worldName) {
|
||||
worldName = worldName.substring(worldName.lastIndexOf('/') + 1);
|
||||
return worldName.substring(worldName.lastIndexOf('\\') + 1);
|
||||
}
|
||||
|
||||
public static Set<Set<Integer>> getBlockEquivalents() {
|
||||
return blockEquivalents;
|
||||
}
|
||||
|
@@ -97,7 +97,7 @@ public class ConnectionPool implements Closeable
|
||||
private boolean inuse;
|
||||
private long timestamp;
|
||||
|
||||
public JDCConnection(Connection conn) {
|
||||
JDCConnection(Connection conn) {
|
||||
this.conn = conn;
|
||||
inuse = false;
|
||||
timestamp = 0;
|
||||
@@ -195,10 +195,6 @@ public class ConnectionPool implements Closeable
|
||||
return conn.getHoldability();
|
||||
}
|
||||
|
||||
public long getLastUse() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseMetaData getMetaData() throws SQLException {
|
||||
return conn.getMetaData();
|
||||
@@ -219,10 +215,6 @@ public class ConnectionPool implements Closeable
|
||||
return conn.getWarnings();
|
||||
}
|
||||
|
||||
public boolean inUse() {
|
||||
return inuse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() throws SQLException {
|
||||
return conn.isClosed();
|
||||
@@ -233,14 +225,6 @@ public class ConnectionPool implements Closeable
|
||||
return conn.isReadOnly();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
try {
|
||||
return conn.isValid(1);
|
||||
} catch (final SQLException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(int timeout) throws SQLException {
|
||||
return conn.isValid(timeout);
|
||||
@@ -251,14 +235,6 @@ public class ConnectionPool implements Closeable
|
||||
return conn.isWrapperFor(iface);
|
||||
}
|
||||
|
||||
public synchronized boolean lease() {
|
||||
if (inuse)
|
||||
return false;
|
||||
inuse = true;
|
||||
timestamp = System.currentTimeMillis();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nativeSQL(String sql) throws SQLException {
|
||||
return conn.nativeSQL(sql);
|
||||
@@ -374,15 +350,39 @@ public class ConnectionPool implements Closeable
|
||||
conn.setTypeMap(map);
|
||||
}
|
||||
|
||||
public void terminate() {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (final SQLException ex) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
return conn.unwrap(iface);
|
||||
}
|
||||
|
||||
long getLastUse() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
boolean inUse() {
|
||||
return inuse;
|
||||
}
|
||||
|
||||
boolean isValid() {
|
||||
try {
|
||||
return conn.isValid(1);
|
||||
} catch (final SQLException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
synchronized boolean lease() {
|
||||
if (inuse)
|
||||
return false;
|
||||
inuse = true;
|
||||
timestamp = System.currentTimeMillis();
|
||||
return true;
|
||||
}
|
||||
|
||||
void terminate() {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (final SQLException ex) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user