forked from LogBlock/LogBlock
Reformat
This commit is contained in:
@@ -127,7 +127,7 @@ public class BlockChange implements LookupCacheElement {
|
||||
msg.append("opened ").append(type.getMaterial().name());
|
||||
} else if (type instanceof Openable) {
|
||||
// Door, Trapdoor, Fence gate
|
||||
msg.append(((Openable)type).isOpen() ? "opened" : "closed").append(" ").append(type.getMaterial().name());
|
||||
msg.append(((Openable) type).isOpen() ? "opened" : "closed").append(" ").append(type.getMaterial().name());
|
||||
} else if (type.getMaterial() == Material.LEVER) {
|
||||
msg.append("switched ").append(type.getMaterial().name()).append(" ").append(((Switch) type).isPowered() ? "on" : "off");
|
||||
} else if (type instanceof Switch) {
|
||||
@@ -152,7 +152,7 @@ public class BlockChange implements LookupCacheElement {
|
||||
} else if (type instanceof Sign || type instanceof WallSign) {
|
||||
msg.append("edited a ").append(type.getMaterial().name()).append(" to ").append(typeDetails);
|
||||
} else {
|
||||
msg.append("replaced ").append(replaced.getMaterial().name()).append(replacedDetails).append(" with ").append(type.getMaterial().name()).append(typeDetails);
|
||||
msg.append("replaced ").append(replaced.getMaterial().name()).append(replacedDetails).append(" with ").append(type.getMaterial().name()).append(typeDetails);
|
||||
}
|
||||
} else if (BukkitUtils.isEmpty(type.getMaterial())) {
|
||||
msg.append("destroyed ").append(replaced.getMaterial().name()).append(replacedDetails);
|
||||
|
@@ -102,7 +102,7 @@ public class CommandsHandler implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.GOLD + "silent -- Displays lesser messages");
|
||||
} else if (command.equals("permissions")) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "You've got the following permissions:");
|
||||
for (final String permission : new String[]{"me", "lookup", "tp", "rollback", "clearlog", "hide", "ignoreRestrictions", "spawnTools"}) {
|
||||
for (final String permission : new String[] { "me", "lookup", "tp", "rollback", "clearlog", "hide", "ignoreRestrictions", "spawnTools" }) {
|
||||
if (logblock.hasPermission(sender, "logblock." + permission)) {
|
||||
sender.sendMessage(ChatColor.GOLD + "logblock." + permission);
|
||||
}
|
||||
@@ -659,15 +659,15 @@ public class CommandsHandler implements CommandExecutor {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if(params.bct == BlockChangeType.CHAT) {
|
||||
if (params.bct == BlockChangeType.CHAT) {
|
||||
sender.sendMessage(ChatColor.RED + "Chat cannot be rolled back");
|
||||
return;
|
||||
}
|
||||
if(params.bct == BlockChangeType.KILLS) {
|
||||
if (params.bct == BlockChangeType.KILLS) {
|
||||
sender.sendMessage(ChatColor.RED + "Kills cannot be rolled back");
|
||||
return;
|
||||
}
|
||||
if(params.sum != SummarizationMode.NONE) {
|
||||
if (params.sum != SummarizationMode.NONE) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot rollback summarized changes");
|
||||
return;
|
||||
}
|
||||
@@ -749,15 +749,15 @@ public class CommandsHandler implements CommandExecutor {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if(params.bct == BlockChangeType.CHAT) {
|
||||
if (params.bct == BlockChangeType.CHAT) {
|
||||
sender.sendMessage(ChatColor.RED + "Chat cannot be redone");
|
||||
return;
|
||||
}
|
||||
if(params.bct == BlockChangeType.KILLS) {
|
||||
if (params.bct == BlockChangeType.KILLS) {
|
||||
sender.sendMessage(ChatColor.RED + "Kills cannot be redone");
|
||||
return;
|
||||
}
|
||||
if(params.sum != SummarizationMode.NONE) {
|
||||
if (params.sum != SummarizationMode.NONE) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot redo summarized changes");
|
||||
return;
|
||||
}
|
||||
@@ -914,7 +914,7 @@ public class CommandsHandler implements CommandExecutor {
|
||||
sb.append(rs.getInt("z"));
|
||||
sb.append(");\n");
|
||||
} else if (params.bct == BlockChangeType.ENTITIES || params.bct == BlockChangeType.ENTITIES_CREATED || params.bct == BlockChangeType.ENTITIES_KILLED) {
|
||||
|
||||
|
||||
} else {
|
||||
sb.append("INSERT INTO `").append(tableBase).append("-blocks` (`id`, `date`, `playerid`, `replaced`, `replacedData`, `type`, `typeData`, `x`, `y`, `z`) VALUES (");
|
||||
sb.append(rs.getInt("id")).append(", FROM_UNIXTIME(");
|
||||
|
@@ -357,7 +357,7 @@ public class Consumer extends Thread {
|
||||
if (hiddenPlayers.contains(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
while(message.length() > 256) {
|
||||
while (message.length() > 256) {
|
||||
addQueueLast(new ChatRow(player, message.substring(0, 256)));
|
||||
message = message.substring(256);
|
||||
}
|
||||
@@ -827,7 +827,7 @@ public class Consumer extends Thread {
|
||||
Location actorBlockLocation = actor.getBlockLocation();
|
||||
if (actorBlockLocation != null) {
|
||||
Integer tempSourceActor = batchHelper.getUncommitedBlockActor(actorBlockLocation);
|
||||
if(tempSourceActor != null) {
|
||||
if (tempSourceActor != null) {
|
||||
sourceActor = tempSourceActor;
|
||||
} else {
|
||||
PreparedStatement smt = batchHelper.getOrPrepareStatement(conn, selectActorIdStatementString, Statement.NO_GENERATED_KEYS);
|
||||
|
@@ -325,12 +325,12 @@ public class LogBlock extends JavaPlugin {
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return super.getFile();
|
||||
}
|
||||
|
||||
|
||||
public Questioner getQuestioner() {
|
||||
return questioner;
|
||||
}
|
||||
|
@@ -1,14 +1,48 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
public enum Logging {
|
||||
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT(true), TNTEXPLOSION(true), CREEPEREXPLOSION(true),
|
||||
GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION(true), FIRE(true), LEAVESDECAY,
|
||||
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
||||
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT,
|
||||
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
|
||||
NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
|
||||
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW, WORLDEDIT, TNTMINECARTEXPLOSION(true),
|
||||
ENDERCRYSTALEXPLOSION(true), BEDEXPLOSION(true), DRAGONEGGTELEPORT(true), DAYLIGHTDETECTORINTERACT,
|
||||
BLOCKPLACE(true),
|
||||
BLOCKBREAK(true),
|
||||
SIGNTEXT(true),
|
||||
TNTEXPLOSION(true),
|
||||
CREEPEREXPLOSION(true),
|
||||
GHASTFIREBALLEXPLOSION(true),
|
||||
ENDERDRAGON(true),
|
||||
MISCEXPLOSION(true),
|
||||
FIRE(true),
|
||||
LEAVESDECAY,
|
||||
LAVAFLOW,
|
||||
WATERFLOW,
|
||||
CHESTACCESS,
|
||||
KILL,
|
||||
CHAT,
|
||||
SNOWFORM,
|
||||
SNOWFADE,
|
||||
DOORINTERACT,
|
||||
SWITCHINTERACT,
|
||||
CAKEEAT,
|
||||
ENDERMEN,
|
||||
NOTEBLOCKINTERACT,
|
||||
DIODEINTERACT,
|
||||
COMPARATORINTERACT,
|
||||
PRESUREPLATEINTERACT,
|
||||
TRIPWIREINTERACT,
|
||||
CREATURECROPTRAMPLE,
|
||||
CROPTRAMPLE,
|
||||
NATURALSTRUCTUREGROW,
|
||||
GRASSGROWTH,
|
||||
MYCELIUMSPREAD,
|
||||
VINEGROWTH,
|
||||
MUSHROOMSPREAD,
|
||||
WITHER(true),
|
||||
WITHER_SKULL(true),
|
||||
BONEMEALSTRUCTUREGROW,
|
||||
WORLDEDIT,
|
||||
TNTMINECARTEXPLOSION(true),
|
||||
ENDERCRYSTALEXPLOSION(true),
|
||||
BEDEXPLOSION(true),
|
||||
DRAGONEGGTELEPORT(true),
|
||||
DAYLIGHTDETECTORINTERACT,
|
||||
LECTERNBOOKCHANGE(true);
|
||||
|
||||
public static final int length = Logging.values().length;
|
||||
|
@@ -22,7 +22,7 @@ public class MaterialConverter {
|
||||
private static String[] idToBlockState = new String[10];
|
||||
private static HashMap<String, Integer> blockStateToID = new HashMap<>();
|
||||
private static int nextBlockStateId;
|
||||
|
||||
|
||||
private static HashMap<String, Material> materialKeyToMaterial = new HashMap<>();
|
||||
|
||||
static {
|
||||
|
@@ -273,7 +273,7 @@ public final class QueryParams implements Cloneable {
|
||||
if (needType) {
|
||||
select += "entitytypeid, action, ";
|
||||
}
|
||||
if(needData) {
|
||||
if (needData) {
|
||||
select += "entityid, entityuuid, data, ";
|
||||
}
|
||||
}
|
||||
@@ -291,21 +291,26 @@ public final class QueryParams implements Cloneable {
|
||||
}
|
||||
if (bct == BlockChangeType.KILLS) {
|
||||
if (sum == SummarizationMode.PLAYERS) {
|
||||
return "SELECT playername, UUID, SUM(kills) AS kills, SUM(killed) AS killed FROM ((SELECT killer AS playerid, count(*) AS kills, 0 as killed FROM `" + getTable() + "-kills` INNER JOIN `lb-players` as killers ON (killer=killers.playerid) INNER JOIN `lb-players` as victims ON (victim=victims.playerid) " + getWhere(BlockChangeType.KILLS) + "GROUP BY killer) UNION (SELECT victim AS playerid, 0 as kills, count(*) AS killed FROM `" + getTable() + "-kills` INNER JOIN `lb-players` as killers ON (killer=killers.playerid) INNER JOIN `lb-players` as victims ON (victim=victims.playerid) " + getWhere(BlockChangeType.KILLS) + "GROUP BY victim)) AS t INNER JOIN `lb-players` USING (playerid) GROUP BY playerid ORDER BY SUM(kills) + SUM(killed) " + order + " " + getLimit();
|
||||
return "SELECT playername, UUID, SUM(kills) AS kills, SUM(killed) AS killed FROM ((SELECT killer AS playerid, count(*) AS kills, 0 as killed FROM `" + getTable() + "-kills` INNER JOIN `lb-players` as killers ON (killer=killers.playerid) INNER JOIN `lb-players` as victims ON (victim=victims.playerid) " + getWhere(BlockChangeType.KILLS) + "GROUP BY killer) UNION (SELECT victim AS playerid, 0 as kills, count(*) AS killed FROM `" + getTable()
|
||||
+ "-kills` INNER JOIN `lb-players` as killers ON (killer=killers.playerid) INNER JOIN `lb-players` as victims ON (victim=victims.playerid) " + getWhere(BlockChangeType.KILLS) + "GROUP BY victim)) AS t INNER JOIN `lb-players` USING (playerid) GROUP BY playerid ORDER BY SUM(kills) + SUM(killed) " + order + " " + getLimit();
|
||||
}
|
||||
throw new IllegalStateException("Invalid summarization for kills");
|
||||
}
|
||||
if (bct == BlockChangeType.ENTITIES || bct == BlockChangeType.ENTITIES_CREATED || bct == BlockChangeType.ENTITIES_KILLED) {
|
||||
if (sum == SummarizationMode.TYPES) {
|
||||
return "SELECT entitytypeid, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT entitytypeid, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-entities` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.ENTITIES_CREATED) + "GROUP BY entitytypeid) UNION (SELECT entitytypeid, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-entities` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.ENTITIES_KILLED) + "GROUP BY entitytypeid)) AS t GROUP BY entitytypeid ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
return "SELECT entitytypeid, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT entitytypeid, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-entities` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.ENTITIES_CREATED) + "GROUP BY entitytypeid) UNION (SELECT entitytypeid, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-entities` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.ENTITIES_KILLED)
|
||||
+ "GROUP BY entitytypeid)) AS t GROUP BY entitytypeid ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
} else {
|
||||
return "SELECT playername, UUID, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT playerid, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-entities` " + getWhere(BlockChangeType.ENTITIES_CREATED) + "GROUP BY playerid) UNION (SELECT playerid, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-entities` " + getWhere(BlockChangeType.ENTITIES_KILLED) + "GROUP BY playerid)) AS t INNER JOIN `lb-players` USING (playerid) GROUP BY playerid ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
return "SELECT playername, UUID, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT playerid, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-entities` " + getWhere(BlockChangeType.ENTITIES_CREATED) + "GROUP BY playerid) UNION (SELECT playerid, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-entities` " + getWhere(BlockChangeType.ENTITIES_KILLED)
|
||||
+ "GROUP BY playerid)) AS t INNER JOIN `lb-players` USING (playerid) GROUP BY playerid ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
}
|
||||
}
|
||||
if (sum == SummarizationMode.TYPES) {
|
||||
return "SELECT type, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT type, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-blocks` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.CREATED) + "GROUP BY type) UNION (SELECT replaced AS type, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-blocks` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.DESTROYED) + "GROUP BY replaced)) AS t GROUP BY type ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
return "SELECT type, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT type, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-blocks` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.CREATED) + "GROUP BY type) UNION (SELECT replaced AS type, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-blocks` INNER JOIN `lb-players` USING (playerid) " + getWhere(BlockChangeType.DESTROYED)
|
||||
+ "GROUP BY replaced)) AS t GROUP BY type ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
} else {
|
||||
return "SELECT playername, UUID, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT playerid, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-blocks` " + getWhere(BlockChangeType.CREATED) + "GROUP BY playerid) UNION (SELECT playerid, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-blocks` " + getWhere(BlockChangeType.DESTROYED) + "GROUP BY playerid)) AS t INNER JOIN `lb-players` USING (playerid) GROUP BY playerid ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
return "SELECT playername, UUID, SUM(created) AS created, SUM(destroyed) AS destroyed FROM ((SELECT playerid, count(*) AS created, 0 AS destroyed FROM `" + getTable() + "-blocks` " + getWhere(BlockChangeType.CREATED) + "GROUP BY playerid) UNION (SELECT playerid, 0 AS created, count(*) AS destroyed FROM `" + getTable() + "-blocks` " + getWhere(BlockChangeType.DESTROYED)
|
||||
+ "GROUP BY playerid)) AS t INNER JOIN `lb-players` USING (playerid) GROUP BY playerid ORDER BY SUM(created) + SUM(destroyed) " + order + " " + getLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,22 +579,20 @@ public final class QueryParams implements Cloneable {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(blockChangeType != BlockChangeType.CHAT) {
|
||||
if (blockChangeType != BlockChangeType.CHAT) {
|
||||
if (loc != null) {
|
||||
if (radius == 0) {
|
||||
compileLocationQuery(
|
||||
where,
|
||||
loc.getBlockX(), loc.getBlockX(),
|
||||
loc.getBlockY(), loc.getBlockY(),
|
||||
loc.getBlockZ(), loc.getBlockZ()
|
||||
);
|
||||
loc.getBlockZ(), loc.getBlockZ());
|
||||
} else if (radius > 0) {
|
||||
compileLocationQuery(
|
||||
where,
|
||||
loc.getBlockX() - radius + 1, loc.getBlockX() + radius - 1,
|
||||
loc.getBlockY() - radius + 1, loc.getBlockY() + radius - 1,
|
||||
loc.getBlockZ() - radius + 1, loc.getBlockZ() + radius - 1
|
||||
);
|
||||
loc.getBlockZ() - radius + 1, loc.getBlockZ() + radius - 1);
|
||||
}
|
||||
|
||||
} else if (sel != null) {
|
||||
@@ -597,8 +600,7 @@ public final class QueryParams implements Cloneable {
|
||||
where,
|
||||
sel.getMinimumPoint().getBlockX(), sel.getMaximumPoint().getBlockX(),
|
||||
sel.getMinimumPoint().getBlockY(), sel.getMaximumPoint().getBlockY(),
|
||||
sel.getMinimumPoint().getBlockZ(), sel.getMaximumPoint().getBlockZ()
|
||||
);
|
||||
sel.getMinimumPoint().getBlockZ(), sel.getMaximumPoint().getBlockZ());
|
||||
}
|
||||
}
|
||||
if (!players.isEmpty() && sum != SummarizationMode.PLAYERS && blockChangeType != BlockChangeType.KILLS) {
|
||||
@@ -1028,14 +1030,26 @@ public final class QueryParams implements Cloneable {
|
||||
}
|
||||
|
||||
public static enum BlockChangeType {
|
||||
ALL, BOTH, CHESTACCESS, CREATED, DESTROYED, CHAT, KILLS, ENTITIES, ENTITIES_CREATED, ENTITIES_KILLED,
|
||||
ALL,
|
||||
BOTH,
|
||||
CHESTACCESS,
|
||||
CREATED,
|
||||
DESTROYED,
|
||||
CHAT,
|
||||
KILLS,
|
||||
ENTITIES,
|
||||
ENTITIES_CREATED,
|
||||
ENTITIES_KILLED,
|
||||
}
|
||||
|
||||
public static enum Order {
|
||||
ASC, DESC
|
||||
ASC,
|
||||
DESC
|
||||
}
|
||||
|
||||
public static enum SummarizationMode {
|
||||
NONE, PLAYERS, TYPES
|
||||
NONE,
|
||||
PLAYERS,
|
||||
TYPES
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
public enum ToolBehavior {
|
||||
TOOL, BLOCK, NONE
|
||||
TOOL,
|
||||
BLOCK,
|
||||
NONE
|
||||
}
|
||||
|
@@ -1,7 +1,11 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
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 ToolMode(String permission) {
|
||||
|
@@ -431,7 +431,7 @@ class Updater {
|
||||
logblock.getLogger().info("Converting " + rowsToConvert + " entries in " + wcfg.table);
|
||||
}
|
||||
rs.close();
|
||||
|
||||
|
||||
PreparedStatement deleteStatement = conn.prepareStatement("DELETE FROM `" + wcfg.table + "` WHERE id = ?");
|
||||
PreparedStatement insertStatement = conn.prepareStatement("INSERT INTO `" + wcfg.table + "-blocks` (id, date, playerid, replaced, replacedData, type, typeData, x, y, z) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
@@ -515,7 +515,7 @@ class Updater {
|
||||
logblock.getLogger().info("Converting " + rowsToConvert + " entries in " + wcfg.table + "-chest");
|
||||
}
|
||||
rs.close();
|
||||
|
||||
|
||||
PreparedStatement insertChestData = conn.prepareStatement("INSERT INTO `" + wcfg.table + "-chestdata` (id, item, itemremove, itemtype) VALUES (?, ?, ?, ?)");
|
||||
PreparedStatement deleteChest = conn.prepareStatement("DELETE FROM `" + wcfg.table + "-chest` WHERE id = ?");
|
||||
while (true) {
|
||||
@@ -532,13 +532,13 @@ class Updater {
|
||||
weaponMaterial = Material.AIR;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack stack = weaponMaterial.getMaxDurability() > 0 ? new ItemStack(weaponMaterial, Math.abs(amount), (short)itemdata) : new ItemStack(weaponMaterial, Math.abs(amount));
|
||||
ItemStack stack = weaponMaterial.getMaxDurability() > 0 ? new ItemStack(weaponMaterial, Math.abs(amount), (short) itemdata) : new ItemStack(weaponMaterial, Math.abs(amount));
|
||||
insertChestData.setInt(1, id);
|
||||
insertChestData.setBytes(2, Utils.saveItemStack(stack));
|
||||
insertChestData.setInt(3, amount >= 0 ? 0 : 1);
|
||||
insertChestData.setInt(4, MaterialConverter.getOrAddMaterialId(weaponMaterial.getKey()));
|
||||
insertChestData.addBatch();
|
||||
|
||||
|
||||
deleteChest.setInt(1, id);
|
||||
deleteChest.addBatch();
|
||||
done++;
|
||||
@@ -578,7 +578,7 @@ class Updater {
|
||||
logblock.getLogger().info("Converting " + rowsToConvert + " entries in " + wcfg.table + "-kills");
|
||||
}
|
||||
rs.close();
|
||||
|
||||
|
||||
PreparedStatement updateWeaponStatement = conn.prepareStatement("UPDATE `" + wcfg.table + "-kills` SET weapon = ? WHERE id = ?");
|
||||
for (int start = 0;; start += OTHER_CONVERT_BATCH_SIZE) {
|
||||
rs = st.executeQuery("SELECT id, weapon FROM `" + wcfg.table + "-kills` ORDER BY id ASC LIMIT " + start + "," + OTHER_CONVERT_BATCH_SIZE);
|
||||
@@ -855,7 +855,7 @@ class Updater {
|
||||
currentMinecraftVersion = currentMinecraftVersion.substring(currentMinecraftVersion.indexOf("(MC: ") + 5);
|
||||
int currentVersionEnd = currentMinecraftVersion.indexOf(" ");
|
||||
int currentVersionEnd2 = currentMinecraftVersion.indexOf(")");
|
||||
if(currentVersionEnd2 >= 0 && (currentVersionEnd < 0 || currentVersionEnd2 < currentVersionEnd)) {
|
||||
if (currentVersionEnd2 >= 0 && (currentVersionEnd < 0 || currentVersionEnd2 < currentVersionEnd)) {
|
||||
currentVersionEnd = currentVersionEnd2;
|
||||
}
|
||||
currentMinecraftVersion = currentMinecraftVersion.substring(0, currentVersionEnd);
|
||||
@@ -944,6 +944,7 @@ class Updater {
|
||||
public static class MaterialUpdater1_13 {
|
||||
BlockData[][] blockDataMapping;
|
||||
Material[][] itemMapping = new Material[10][];
|
||||
|
||||
public MaterialUpdater1_13(LogBlock plugin) throws IOException {
|
||||
blockDataMapping = new BlockData[256][16];
|
||||
try (JarFile file = new JarFile(plugin.getFile())) {
|
||||
|
@@ -91,7 +91,6 @@ public class WorldEditor implements Runnable {
|
||||
return blacklistCollisions;
|
||||
}
|
||||
|
||||
|
||||
public void setSender(CommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
@@ -202,12 +201,14 @@ public class WorldEditor implements Runnable {
|
||||
}
|
||||
|
||||
public static enum PerformResult {
|
||||
SUCCESS, BLACKLISTED, NO_ACTION
|
||||
SUCCESS,
|
||||
BLACKLISTED,
|
||||
NO_ACTION
|
||||
}
|
||||
|
||||
public interface Edit {
|
||||
PerformResult perform() throws WorldEditorException;
|
||||
|
||||
|
||||
public long getTime();
|
||||
}
|
||||
|
||||
@@ -440,6 +441,7 @@ public class WorldEditor implements Runnable {
|
||||
|
||||
public static class EditComparator implements Comparator<Edit> {
|
||||
private final int mult;
|
||||
|
||||
public EditComparator(QueryParams.Order order) {
|
||||
mult = order == Order.DESC ? 1 : -1;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ public class WorldEditorEditFactory {
|
||||
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
if (params.bct == BlockChangeType.ENTITIES) {
|
||||
editor.queueEntityEdit(rs, params, rollback);
|
||||
editor.queueEntityEdit(rs, params, rollback);
|
||||
return;
|
||||
}
|
||||
ChestAccess chestaccess = null;
|
||||
|
@@ -58,7 +58,9 @@ public class Config {
|
||||
public static boolean mb4 = false;
|
||||
|
||||
public static enum LogKillsLevel {
|
||||
PLAYERS, MONSTERS, ANIMALS;
|
||||
PLAYERS,
|
||||
MONSTERS,
|
||||
ANIMALS;
|
||||
}
|
||||
|
||||
public static void load(LogBlock logblock) throws DataFormatException, IOException {
|
||||
@@ -158,10 +160,10 @@ public class Config {
|
||||
}
|
||||
}
|
||||
logblock.saveConfig();
|
||||
|
||||
|
||||
ComparableVersion configVersion = new ComparableVersion(config.getString("version"));
|
||||
boolean oldConfig = configVersion.compareTo(new ComparableVersion(logblock.getDescription().getVersion().replace(" (manually compiled)", ""))) < 0;
|
||||
|
||||
|
||||
url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port") + "/" + getStringIncludingInts(config, "mysql.database");
|
||||
user = getStringIncludingInts(config, "mysql.user");
|
||||
password = getStringIncludingInts(config, "mysql.password");
|
||||
@@ -246,7 +248,7 @@ public class Config {
|
||||
final ToolBehavior leftClickBehavior = ToolBehavior.valueOf(tSec.getString("leftClickBehavior").toUpperCase());
|
||||
final ToolBehavior rightClickBehavior = ToolBehavior.valueOf(tSec.getString("rightClickBehavior").toUpperCase());
|
||||
final boolean defaultEnabled = tSec.getBoolean("defaultEnabled", false);
|
||||
final Material item = Material.matchMaterial(tSec.getString("item","OAK_LOG"));
|
||||
final Material item = Material.matchMaterial(tSec.getString("item", "OAK_LOG"));
|
||||
final boolean canDrop = tSec.getBoolean("canDrop", false);
|
||||
final boolean removeOnDisable = tSec.getBoolean("removeOnDisable", true);
|
||||
final boolean dropToDisable = tSec.getBoolean("dropToDisable", false);
|
||||
|
@@ -43,13 +43,13 @@ public class BlockBurnLogging extends LoggingListener {
|
||||
} else {
|
||||
actor = new Actor("Dispenser");
|
||||
}
|
||||
} else if(event.getCause() == IgniteCause.LIGHTNING) {
|
||||
} else if (event.getCause() == IgniteCause.LIGHTNING) {
|
||||
actor = new Actor("Lightning");
|
||||
} else if(event.getCause() == IgniteCause.EXPLOSION) {
|
||||
} else if (event.getCause() == IgniteCause.EXPLOSION) {
|
||||
actor = new Actor("Explosion");
|
||||
} else if(event.getCause() == IgniteCause.LAVA) {
|
||||
} else if (event.getCause() == IgniteCause.LAVA) {
|
||||
actor = new Actor("Lava");
|
||||
} else if(event.getCause() == IgniteCause.ENDER_CRYSTAL) {
|
||||
} else if (event.getCause() == IgniteCause.ENDER_CRYSTAL) {
|
||||
actor = new Actor("EnderCrystal");
|
||||
}
|
||||
if (isLogging(event.getBlock().getWorld(), Logging.FIRE)) {
|
||||
|
@@ -65,4 +65,3 @@ public class CreatureInteractLogging extends LoggingListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -100,7 +100,7 @@ public class ExplosionLogging extends LoggingListener {
|
||||
}
|
||||
actor = Actor.actorFromEntity(source);
|
||||
|
||||
} else if (source instanceof EnderCrystal){
|
||||
} else if (source instanceof EnderCrystal) {
|
||||
if (!wcfg.isLogging(Logging.ENDERCRYSTALEXPLOSION)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class FluidFlowLogging extends LoggingListener {
|
||||
if (typeFrom == Material.SEAGRASS || typeFrom == Material.KELP_PLANT || typeFrom == Material.KELP) {
|
||||
typeFrom = Material.WATER;
|
||||
fromWaterlogged = true;
|
||||
}
|
||||
}
|
||||
|
||||
Block source = Config.logFluidFlowAsPlayerWhoTriggeredIt ? event.getBlock() : null;
|
||||
final Block to = event.getToBlock();
|
||||
|
@@ -16,7 +16,6 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import static de.diddiz.LogBlock.config.Config.*;
|
||||
|
||||
|
||||
public class KillLogging extends LoggingListener {
|
||||
|
||||
public KillLogging(LogBlock lb) {
|
||||
|
@@ -16,12 +16,6 @@ public class SnowFormLogging extends LoggingListener {
|
||||
super(lb);
|
||||
}
|
||||
|
||||
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
// public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
// if (isLogging(event.getBlock().getWorld(), Logging.SNOWFORM))
|
||||
// consumer.queueBlockBreak("LeavesDecay", event.getBlock().getState());
|
||||
// }
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockForm(BlockFormEvent event) {
|
||||
if (isLogging(event.getBlock().getWorld(), Logging.SNOWFORM)) {
|
||||
|
@@ -141,14 +141,14 @@ public class BukkitUtils {
|
||||
singleBlockPlants.add(Material.WHITE_TULIP);
|
||||
singleBlockPlants.add(Material.PINK_TULIP);
|
||||
singleBlockPlants.add(Material.RED_TULIP);
|
||||
singleBlockPlants.add(Material.OXEYE_DAISY);
|
||||
singleBlockPlants.add(Material.OXEYE_DAISY);
|
||||
singleBlockPlants.add(Material.BROWN_MUSHROOM);
|
||||
singleBlockPlants.add(Material.RED_MUSHROOM);
|
||||
singleBlockPlants.add(Material.SWEET_BERRY_BUSH);
|
||||
singleBlockPlants.add(Material.LILY_OF_THE_VALLEY);
|
||||
singleBlockPlants.add(Material.CORNFLOWER);
|
||||
singleBlockPlants.add(Material.WITHER_ROSE);
|
||||
|
||||
|
||||
doublePlants = EnumSet.noneOf(Material.class);
|
||||
doublePlants.add(Material.TALL_GRASS);
|
||||
doublePlants.add(Material.LARGE_FERN);
|
||||
@@ -157,7 +157,7 @@ public class BukkitUtils {
|
||||
doublePlants.add(Material.LILAC);
|
||||
doublePlants.add(Material.SUNFLOWER);
|
||||
doublePlants.add(Material.PEONY);
|
||||
|
||||
|
||||
blockEquivalents = new HashSet<Set<Integer>>(7);
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(2, 3, 60)));
|
||||
blockEquivalents.add(new HashSet<Integer>(Arrays.asList(8, 9, 79)));
|
||||
@@ -218,9 +218,9 @@ public class BukkitUtils {
|
||||
relativeTopBreakable.addAll(doublePlants);
|
||||
relativeTopBreakable.add(Material.BAMBOO);
|
||||
relativeTopBreakable.add(Material.BAMBOO_SAPLING);
|
||||
for(Material m : Material.values()) {
|
||||
if(m.name().startsWith("POTTED_")) {
|
||||
relativeTopBreakable.add(m);
|
||||
for (Material m : Material.values()) {
|
||||
if (m.name().startsWith("POTTED_")) {
|
||||
relativeTopBreakable.add(m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class BukkitUtils {
|
||||
fallingEntityKillers.add(Material.WHITE_TULIP);
|
||||
fallingEntityKillers.add(Material.PINK_TULIP);
|
||||
fallingEntityKillers.add(Material.RED_TULIP);
|
||||
fallingEntityKillers.add(Material.OXEYE_DAISY);
|
||||
fallingEntityKillers.add(Material.OXEYE_DAISY);
|
||||
fallingEntityKillers.add(Material.BROWN_MUSHROOM);
|
||||
fallingEntityKillers.add(Material.RED_MUSHROOM);
|
||||
fallingEntityKillers.addAll(doublePlants);
|
||||
@@ -336,8 +336,8 @@ public class BukkitUtils {
|
||||
projectileItems.put(EntityType.ARROW, Material.ARROW);
|
||||
projectileItems.put(EntityType.EGG, Material.EGG);
|
||||
projectileItems.put(EntityType.ENDER_PEARL, Material.ENDER_PEARL);
|
||||
projectileItems.put(EntityType.SMALL_FIREBALL, Material.FIRE_CHARGE); // Fire charge
|
||||
projectileItems.put(EntityType.FIREBALL, Material.FIRE_CHARGE); // Fire charge
|
||||
projectileItems.put(EntityType.SMALL_FIREBALL, Material.FIRE_CHARGE); // Fire charge
|
||||
projectileItems.put(EntityType.FIREBALL, Material.FIRE_CHARGE); // Fire charge
|
||||
projectileItems.put(EntityType.FISHING_HOOK, Material.FISHING_ROD);
|
||||
projectileItems.put(EntityType.SNOWBALL, Material.SNOWBALL);
|
||||
projectileItems.put(EntityType.SPLASH_POTION, Material.SPLASH_POTION);
|
||||
@@ -429,7 +429,7 @@ public class BukkitUtils {
|
||||
dyes.put(Material.YELLOW_DYE, DyeColor.YELLOW);
|
||||
}
|
||||
|
||||
private static final BlockFace[] relativeBlockFaces = new BlockFace[]{
|
||||
private static final BlockFace[] relativeBlockFaces = new BlockFace[] {
|
||||
BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.UP, BlockFace.DOWN
|
||||
};
|
||||
|
||||
@@ -556,7 +556,7 @@ public class BukkitUtils {
|
||||
public static Set<Material> getFallingEntityKillers() {
|
||||
return fallingEntityKillers;
|
||||
}
|
||||
|
||||
|
||||
public static Set<Material> getNonFluidProofBlocks() {
|
||||
return nonFluidProofBlocks;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ public class BukkitUtils {
|
||||
public static Material itemIDfromProjectileEntity(Entity e) {
|
||||
return projectileItems.get(e.getType());
|
||||
}
|
||||
|
||||
|
||||
public static boolean isDoublePlant(Material m) {
|
||||
return doublePlants.contains(m);
|
||||
}
|
||||
@@ -799,7 +799,7 @@ public class BukkitUtils {
|
||||
if (face.getType() == chestBlock.getType()) {
|
||||
// check is the neighbour connects to this chest
|
||||
org.bukkit.block.data.type.Chest otherChestData = (org.bukkit.block.data.type.Chest) face.getBlockData();
|
||||
if(otherChestData.getType() != wantedChestType || otherChestData.getFacing() != chestFace) {
|
||||
if (otherChestData.getType() != wantedChestType || otherChestData.getFacing() != chestFace) {
|
||||
return null;
|
||||
}
|
||||
return face;
|
||||
|
@@ -61,22 +61,19 @@ import java.util.Stack;
|
||||
* @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
|
||||
* @author <a href="mailto:hboutemy@apache.org">Hervé Boutemy</a>
|
||||
*/
|
||||
public class ComparableVersion
|
||||
implements Comparable<ComparableVersion>
|
||||
{
|
||||
public class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
private String value;
|
||||
|
||||
private String canonical;
|
||||
|
||||
private ListItem items;
|
||||
|
||||
private interface Item
|
||||
{
|
||||
private interface Item {
|
||||
int INTEGER_ITEM = 0;
|
||||
int STRING_ITEM = 1;
|
||||
int LIST_ITEM = 2;
|
||||
|
||||
int compareTo( Item item );
|
||||
int compareTo(Item item);
|
||||
|
||||
int getType();
|
||||
|
||||
@@ -86,46 +83,37 @@ public class ComparableVersion
|
||||
/**
|
||||
* Represents a numeric item in the version item list.
|
||||
*/
|
||||
private static class IntegerItem
|
||||
implements Item
|
||||
{
|
||||
private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" );
|
||||
private static class IntegerItem implements Item {
|
||||
private static final BigInteger BIG_INTEGER_ZERO = new BigInteger("0");
|
||||
|
||||
private final BigInteger value;
|
||||
|
||||
public static final IntegerItem ZERO = new IntegerItem();
|
||||
|
||||
private IntegerItem()
|
||||
{
|
||||
private IntegerItem() {
|
||||
this.value = BIG_INTEGER_ZERO;
|
||||
}
|
||||
|
||||
public IntegerItem( String str )
|
||||
{
|
||||
this.value = new BigInteger( str );
|
||||
public IntegerItem(String str) {
|
||||
this.value = new BigInteger(str);
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
public int getType() {
|
||||
return INTEGER_ITEM;
|
||||
}
|
||||
|
||||
public boolean isNull()
|
||||
{
|
||||
return BIG_INTEGER_ZERO.equals( value );
|
||||
public boolean isNull() {
|
||||
return BIG_INTEGER_ZERO.equals(value);
|
||||
}
|
||||
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
return BIG_INTEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
|
||||
public int compareTo(Item item) {
|
||||
if (item == null) {
|
||||
return BIG_INTEGER_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1
|
||||
}
|
||||
|
||||
switch ( item.getType() )
|
||||
{
|
||||
switch (item.getType()) {
|
||||
case INTEGER_ITEM:
|
||||
return value.compareTo( ( (IntegerItem) item ).value );
|
||||
return value.compareTo(((IntegerItem) item).value);
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
@@ -134,12 +122,11 @@ public class ComparableVersion
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new RuntimeException( "invalid item: " + item.getClass() );
|
||||
throw new RuntimeException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -147,36 +134,30 @@ public class ComparableVersion
|
||||
/**
|
||||
* Represents a string in the version item list, usually a qualifier.
|
||||
*/
|
||||
private static class StringItem
|
||||
implements Item
|
||||
{
|
||||
private static class StringItem implements Item {
|
||||
private static final String[] QUALIFIERS = { "alpha", "beta", "milestone", "rc", "snapshot", "", "sp" };
|
||||
|
||||
private static final List<String> _QUALIFIERS = Arrays.asList( QUALIFIERS );
|
||||
private static final List<String> _QUALIFIERS = Arrays.asList(QUALIFIERS);
|
||||
|
||||
private static final Properties ALIASES = new Properties();
|
||||
static
|
||||
{
|
||||
ALIASES.put( "ga", "" );
|
||||
ALIASES.put( "final", "" );
|
||||
ALIASES.put( "cr", "rc" );
|
||||
static {
|
||||
ALIASES.put("ga", "");
|
||||
ALIASES.put("final", "");
|
||||
ALIASES.put("cr", "rc");
|
||||
}
|
||||
|
||||
/**
|
||||
* A comparable value for the empty-string qualifier. This one is used to determine if a given qualifier makes
|
||||
* the version older than one without a qualifier, or more recent.
|
||||
*/
|
||||
private static final String RELEASE_VERSION_INDEX = String.valueOf( _QUALIFIERS.indexOf( "" ) );
|
||||
private static final String RELEASE_VERSION_INDEX = String.valueOf(_QUALIFIERS.indexOf(""));
|
||||
|
||||
private String value;
|
||||
|
||||
public StringItem( String value, boolean followedByDigit )
|
||||
{
|
||||
if ( followedByDigit && value.length() == 1 )
|
||||
{
|
||||
public StringItem(String value, boolean followedByDigit) {
|
||||
if (followedByDigit && value.length() == 1) {
|
||||
// a1 = alpha-1, b1 = beta-1, m1 = milestone-1
|
||||
switch ( value.charAt( 0 ) )
|
||||
{
|
||||
switch (value.charAt(0)) {
|
||||
case 'a':
|
||||
value = "alpha";
|
||||
break;
|
||||
@@ -188,17 +169,15 @@ public class ComparableVersion
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.value = ALIASES.getProperty( value , value );
|
||||
this.value = ALIASES.getProperty(value, value);
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
public int getType() {
|
||||
return STRING_ITEM;
|
||||
}
|
||||
|
||||
public boolean isNull()
|
||||
{
|
||||
return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 );
|
||||
public boolean isNull() {
|
||||
return (comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,38 +192,33 @@ public class ComparableVersion
|
||||
* @param qualifier
|
||||
* @return an equivalent value that can be used with lexical comparison
|
||||
*/
|
||||
public static String comparableQualifier( String qualifier )
|
||||
{
|
||||
int i = _QUALIFIERS.indexOf( qualifier );
|
||||
public static String comparableQualifier(String qualifier) {
|
||||
int i = _QUALIFIERS.indexOf(qualifier);
|
||||
|
||||
return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i );
|
||||
return i == -1 ? (_QUALIFIERS.size() + "-" + qualifier) : String.valueOf(i);
|
||||
}
|
||||
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
public int compareTo(Item item) {
|
||||
if (item == null) {
|
||||
// 1-rc < 1, 1-ga > 1
|
||||
return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX );
|
||||
return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX);
|
||||
}
|
||||
switch ( item.getType() )
|
||||
{
|
||||
switch (item.getType()) {
|
||||
case INTEGER_ITEM:
|
||||
return -1; // 1.any < 1.1 ?
|
||||
|
||||
case STRING_ITEM:
|
||||
return comparableQualifier( value ).compareTo( comparableQualifier( ( (StringItem) item ).value ) );
|
||||
return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value));
|
||||
|
||||
case LIST_ITEM:
|
||||
return -1; // 1.any < 1-1
|
||||
|
||||
default:
|
||||
throw new RuntimeException( "invalid item: " + item.getClass() );
|
||||
throw new RuntimeException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -253,51 +227,37 @@ public class ComparableVersion
|
||||
* Represents a version list item. This class is used both for the global item list and for sub-lists (which start
|
||||
* with '-(number)' in the version specification).
|
||||
*/
|
||||
private static class ListItem
|
||||
extends ArrayList<Item>
|
||||
implements Item
|
||||
{
|
||||
private static class ListItem extends ArrayList<Item> implements Item {
|
||||
private static final long serialVersionUID = 5914575811857700009L;
|
||||
|
||||
public int getType()
|
||||
{
|
||||
public int getType() {
|
||||
return LIST_ITEM;
|
||||
}
|
||||
|
||||
public boolean isNull()
|
||||
{
|
||||
return ( size() == 0 );
|
||||
public boolean isNull() {
|
||||
return (size() == 0);
|
||||
}
|
||||
|
||||
void normalize()
|
||||
{
|
||||
for ( ListIterator<Item> iterator = listIterator( size() ); iterator.hasPrevious(); )
|
||||
{
|
||||
void normalize() {
|
||||
for (ListIterator<Item> iterator = listIterator(size()); iterator.hasPrevious();) {
|
||||
Item item = iterator.previous();
|
||||
if ( item.isNull() )
|
||||
{
|
||||
if (item.isNull()) {
|
||||
iterator.remove(); // remove null trailing items: 0, "", empty list
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
if ( size() == 0 )
|
||||
{
|
||||
public int compareTo(Item item) {
|
||||
if (item == null) {
|
||||
if (size() == 0) {
|
||||
return 0; // 1-0 = 1- (normalize) = 1
|
||||
}
|
||||
Item first = get( 0 );
|
||||
return first.compareTo( null );
|
||||
Item first = get(0);
|
||||
return first.compareTo(null);
|
||||
}
|
||||
switch ( item.getType() )
|
||||
{
|
||||
switch (item.getType()) {
|
||||
case INTEGER_ITEM:
|
||||
return -1; // 1-1 < 1.0.x
|
||||
|
||||
@@ -306,18 +266,16 @@ public class ComparableVersion
|
||||
|
||||
case LIST_ITEM:
|
||||
Iterator<Item> left = iterator();
|
||||
Iterator<Item> right = ( (ListItem) item ).iterator();
|
||||
Iterator<Item> right = ((ListItem) item).iterator();
|
||||
|
||||
while ( left.hasNext() || right.hasNext() )
|
||||
{
|
||||
while (left.hasNext() || right.hasNext()) {
|
||||
Item l = left.hasNext() ? left.next() : null;
|
||||
Item r = right.hasNext() ? right.next() : null;
|
||||
|
||||
// if this is shorter, then invert the compare and mul with -1
|
||||
int result = l == null ? ( r == null ? 0 : -1 * r.compareTo( l ) ) : l.compareTo( r );
|
||||
int result = l == null ? (r == null ? 0 : -1 * r.compareTo(l)) : l.compareTo(r);
|
||||
|
||||
if ( result != 0 )
|
||||
{
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -325,105 +283,82 @@ public class ComparableVersion
|
||||
return 0;
|
||||
|
||||
default:
|
||||
throw new RuntimeException( "invalid item: " + item.getClass() );
|
||||
throw new RuntimeException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder( "(" );
|
||||
for ( Iterator<Item> iter = iterator(); iter.hasNext(); )
|
||||
{
|
||||
buffer.append( iter.next() );
|
||||
if ( iter.hasNext() )
|
||||
{
|
||||
buffer.append( ',' );
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder("(");
|
||||
for (Iterator<Item> iter = iterator(); iter.hasNext();) {
|
||||
buffer.append(iter.next());
|
||||
if (iter.hasNext()) {
|
||||
buffer.append(',');
|
||||
}
|
||||
}
|
||||
buffer.append( ')' );
|
||||
buffer.append(')');
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public ComparableVersion( String version )
|
||||
{
|
||||
parseVersion( version );
|
||||
public ComparableVersion(String version) {
|
||||
parseVersion(version);
|
||||
}
|
||||
|
||||
public final void parseVersion( String version )
|
||||
{
|
||||
public final void parseVersion(String version) {
|
||||
this.value = version;
|
||||
|
||||
items = new ListItem();
|
||||
|
||||
version = version.toLowerCase( Locale.ENGLISH );
|
||||
version = version.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
ListItem list = items;
|
||||
|
||||
Stack<Item> stack = new Stack<Item>();
|
||||
stack.push( list );
|
||||
stack.push(list);
|
||||
|
||||
boolean isDigit = false;
|
||||
|
||||
int startIndex = 0;
|
||||
|
||||
for ( int i = 0; i < version.length(); i++ )
|
||||
{
|
||||
char c = version.charAt( i );
|
||||
for (int i = 0; i < version.length(); i++) {
|
||||
char c = version.charAt(i);
|
||||
|
||||
if ( c == '.' )
|
||||
{
|
||||
if ( i == startIndex )
|
||||
{
|
||||
list.add( IntegerItem.ZERO );
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add( parseItem( isDigit, version.substring( startIndex, i ) ) );
|
||||
if (c == '.') {
|
||||
if (i == startIndex) {
|
||||
list.add(IntegerItem.ZERO);
|
||||
} else {
|
||||
list.add(parseItem(isDigit, version.substring(startIndex, i)));
|
||||
}
|
||||
startIndex = i + 1;
|
||||
}
|
||||
else if ( c == '-' )
|
||||
{
|
||||
if ( i == startIndex )
|
||||
{
|
||||
list.add( IntegerItem.ZERO );
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add( parseItem( isDigit, version.substring( startIndex, i ) ) );
|
||||
} else if (c == '-') {
|
||||
if (i == startIndex) {
|
||||
list.add(IntegerItem.ZERO);
|
||||
} else {
|
||||
list.add(parseItem(isDigit, version.substring(startIndex, i)));
|
||||
}
|
||||
startIndex = i + 1;
|
||||
|
||||
if ( isDigit )
|
||||
{
|
||||
if (isDigit) {
|
||||
list.normalize(); // 1.0-* = 1-*
|
||||
|
||||
if ( ( i + 1 < version.length() ) && Character.isDigit( version.charAt( i + 1 ) ) )
|
||||
{
|
||||
if ((i + 1 < version.length()) && Character.isDigit(version.charAt(i + 1))) {
|
||||
// new ListItem only if previous were digits and new char is a digit,
|
||||
// ie need to differentiate only 1.1 from 1-1
|
||||
list.add( list = new ListItem() );
|
||||
list.add(list = new ListItem());
|
||||
|
||||
stack.push( list );
|
||||
stack.push(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Character.isDigit( c ) )
|
||||
{
|
||||
if ( !isDigit && i > startIndex )
|
||||
{
|
||||
list.add( new StringItem( version.substring( startIndex, i ), true ) );
|
||||
} else if (Character.isDigit(c)) {
|
||||
if (!isDigit && i > startIndex) {
|
||||
list.add(new StringItem(version.substring(startIndex, i), true));
|
||||
startIndex = i;
|
||||
}
|
||||
|
||||
isDigit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isDigit && i > startIndex )
|
||||
{
|
||||
list.add( parseItem( true, version.substring( startIndex, i ) ) );
|
||||
} else {
|
||||
if (isDigit && i > startIndex) {
|
||||
list.add(parseItem(true, version.substring(startIndex, i)));
|
||||
startIndex = i;
|
||||
}
|
||||
|
||||
@@ -431,13 +366,11 @@ public class ComparableVersion
|
||||
}
|
||||
}
|
||||
|
||||
if ( version.length() > startIndex )
|
||||
{
|
||||
list.add( parseItem( isDigit, version.substring( startIndex ) ) );
|
||||
if (version.length() > startIndex) {
|
||||
list.add(parseItem(isDigit, version.substring(startIndex)));
|
||||
}
|
||||
|
||||
while ( !stack.isEmpty() )
|
||||
{
|
||||
while (!stack.isEmpty()) {
|
||||
list = (ListItem) stack.pop();
|
||||
list.normalize();
|
||||
}
|
||||
@@ -445,39 +378,31 @@ public class ComparableVersion
|
||||
canonical = items.toString();
|
||||
}
|
||||
|
||||
private static Item parseItem( boolean isDigit, String buf )
|
||||
{
|
||||
return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false );
|
||||
private static Item parseItem(boolean isDigit, String buf) {
|
||||
return isDigit ? new IntegerItem(buf) : new StringItem(buf, false);
|
||||
}
|
||||
|
||||
public int compareTo( ComparableVersion o )
|
||||
{
|
||||
return items.compareTo( o.items );
|
||||
public int compareTo(ComparableVersion o) {
|
||||
return items.compareTo(o.items);
|
||||
}
|
||||
|
||||
public int compareTo( String version )
|
||||
{
|
||||
public int compareTo(String version) {
|
||||
return compareTo(new ComparableVersion(version));
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String toCanonicalString()
|
||||
{
|
||||
public String toCanonicalString() {
|
||||
return canonical;
|
||||
}
|
||||
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical );
|
||||
public boolean equals(Object o) {
|
||||
return (o instanceof ComparableVersion) && canonical.equals(((ComparableVersion) o).canonical);
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
public int hashCode() {
|
||||
return canonical.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import static de.diddiz.LogBlock.config.Config.mb4;
|
||||
|
||||
public class LoggingUtil {
|
||||
|
||||
public static void smartLogBlockPlace(Consumer consumer, Actor actor, BlockState replaced, BlockState placed) {
|
||||
public static void smartLogBlockPlace(Consumer consumer, Actor actor, BlockState replaced, BlockState placed) {
|
||||
Location loc = replaced.getLocation();
|
||||
if (!placed.getType().hasGravity() || !BukkitUtils.canDirectlyFallIn(replaced.getBlock().getRelative(BlockFace.DOWN).getType())) {
|
||||
if (BukkitUtils.isEmpty(replaced.getType())) {
|
||||
@@ -141,32 +141,32 @@ public class LoggingUtil {
|
||||
} else {
|
||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||
}
|
||||
} else if(typeAbove == Material.LANTERN) {
|
||||
} else if (typeAbove == Material.LANTERN) {
|
||||
Lantern lantern = (Lantern) checkBlock.getBlockData();
|
||||
if(!lantern.isHanging()) {
|
||||
if (!lantern.isHanging()) {
|
||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||
}
|
||||
}else if(typeAbove == Material.BELL) {
|
||||
} else if (typeAbove == Material.BELL) {
|
||||
Bell bell = (Bell) checkBlock.getBlockData();
|
||||
if(bell.getAttachment() == Attachment.FLOOR) {
|
||||
if (bell.getAttachment() == Attachment.FLOOR) {
|
||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkBlock = origin.getRelative(BlockFace.DOWN);
|
||||
Material typeBelow = checkBlock.getType();
|
||||
if(typeBelow == Material.LANTERN) {
|
||||
if (typeBelow == Material.LANTERN) {
|
||||
Lantern lantern = (Lantern) checkBlock.getBlockData();
|
||||
if(lantern.isHanging()) {
|
||||
if (lantern.isHanging()) {
|
||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||
}
|
||||
} else if(typeBelow == Material.BELL) {
|
||||
} else if (typeBelow == Material.BELL) {
|
||||
Bell bell = (Bell) checkBlock.getBlockData();
|
||||
if(bell.getAttachment() == Attachment.CEILING) {
|
||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||
if (bell.getAttachment() == Attachment.CEILING) {
|
||||
consumer.queueBlockBreak(actor, checkBlock.getState());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<Location> relativeBreakables = BukkitUtils.getBlocksNearby(origin, BukkitUtils.getRelativeBreakables());
|
||||
if (relativeBreakables.size() != 0) {
|
||||
for (Location location : relativeBreakables) {
|
||||
|
@@ -29,7 +29,7 @@ public class MySQLConnectionPool implements Closeable {
|
||||
ds.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
ds.addDataSourceProperty("useServerPrepStmts", "true");
|
||||
|
||||
|
||||
ds.addDataSourceProperty("useSSL", "true");
|
||||
ds.addDataSourceProperty("requireSSL", Boolean.toString(requireSSL));
|
||||
ds.addDataSourceProperty("verifyServerCertificate", "false");
|
||||
|
@@ -21,12 +21,12 @@ public class CuboidRegion implements Cloneable {
|
||||
|
||||
public CuboidRegion(World world, BlockVector first, BlockVector second) {
|
||||
this.world = world;
|
||||
this.min.setX(Math.min(first.getBlockX(),second.getBlockX()));
|
||||
this.min.setY(Math.min(first.getBlockY(),second.getBlockY()));
|
||||
this.min.setZ(Math.min(first.getBlockZ(),second.getBlockZ()));
|
||||
this.max.setX(Math.max(first.getBlockX(),second.getBlockX()));
|
||||
this.max.setY(Math.max(first.getBlockY(),second.getBlockY()));
|
||||
this.max.setZ(Math.max(first.getBlockZ(),second.getBlockZ()));
|
||||
this.min.setX(Math.min(first.getBlockX(), second.getBlockX()));
|
||||
this.min.setY(Math.min(first.getBlockY(), second.getBlockY()));
|
||||
this.min.setZ(Math.min(first.getBlockZ(), second.getBlockZ()));
|
||||
this.max.setX(Math.max(first.getBlockX(), second.getBlockX()));
|
||||
this.max.setY(Math.max(first.getBlockY(), second.getBlockY()));
|
||||
this.max.setZ(Math.max(first.getBlockZ(), second.getBlockZ()));
|
||||
}
|
||||
|
||||
public static CuboidRegion fromPlayerSelection(Player player) {
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
|
||||
import de.diddiz.util.Utils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
Reference in New Issue
Block a user